File tree Expand file tree Collapse file tree 3 files changed +16
-24
lines changed
Expand file tree Collapse file tree 3 files changed +16
-24
lines changed Original file line number Diff line number Diff line change 44
55deps :
66 pip3 install --upgrade setuptools
7- pip3 install django==3.2.8 django-cockroachdb==3.2.1 psycopg2
7+ pip3 install django==3.2.8 django-cockroachdb==3.2.1 psycopg2 dj-database-url==0.5.0
Original file line number Diff line number Diff line change 1010https://docs.djangoproject.com/en/2.2/ref/settings/
1111"""
1212
13+ import dj_database_url
1314import os
1415
1516from urllib .parse import urlparse
7677# Database
7778# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
7879
79- port = 26257
80+ DATABASES = {}
8081addr = os .getenv ('ADDR' )
8182if addr is not None :
8283 url = urlparse (addr )
83- port = url . port
84-
85- DATABASES = {
86- 'default' : {
84+ DATABASES [ 'default' ] = dj_database_url . config ( default = addr , engine = 'django_cockroachdb' )
85+ DATABASES [ 'default' ][ 'DISABLE_COCKROACHDB_TELEMETRY' ] = True
86+ else :
87+ DATABASES [ 'default' ] = {
8788 'ENGINE' : 'django_cockroachdb' ,
8889 'NAME' : 'company_django' ,
8990 'USER' : 'root' ,
90- 'PASSWORD' : '' ,
9191 'HOST' : 'localhost' ,
92- 'PORT' : port ,
92+ 'PORT' : 26257 ,
9393 'DISABLE_COCKROACHDB_TELEMETRY' : True ,
9494 }
95- }
96-
9795
9896# Password validation
9997# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
Original file line number Diff line number Diff line change @@ -474,20 +474,14 @@ func TestSQLAlchemy(t *testing.T) {
474474}
475475
476476func TestDjango (t * testing.T ) {
477- testORMForAuthModesExcept (t , testInfo {
478- language : "python" ,
479- orm : "django" ,
480- tableNames : djangoTestTableNames ,
481- columnNames : djangoTestColumnNames ,
482- },
483- map [authMode ]string {
484- // No support for client certs (at least not via the query string).
485- // psycopg2.OperationalError: fe_sendauth: no password supplied
486- //authClientCert: "client certs via query string unsupported",
487- // Ditto,
488- // psycopg2.OperationalError: fe_sendauth: no password supplied
489- //authPassword: "password via query string unsupported",
490- },
477+ testORMForAuthModesExcept (
478+ t ,
479+ testInfo {
480+ language : "python" ,
481+ orm : "django" ,
482+ tableNames : djangoTestTableNames ,
483+ columnNames : djangoTestColumnNames ,
484+ }, nothingSkipped (),
491485 )
492486}
493487
You can’t perform that action at this time.
0 commit comments