10000 modifying import settings · asthamohta/python-spanner-django@9cabe18 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9cabe18

Browse files
committed
modifying import settings
1 parent 35b2bad commit 9cabe18

14 files changed

+19
-52
lines changed

README.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ workloads.
1414
- `Product Documentation`_
1515

1616
.. _Cloud Spanner: https://cloud.google.com/spanner/
17-
.. _Client Library Documentation: https://googleapis.dev/python/django-google-spanner/2.2.1b1/index.html
17+
.. _Client Library Documentation: https://googleapis.dev/python/django-google-spanner/latest/index.html
1818
.. _Product Documentation: https://cloud.google.com/spanner/docs
1919

2020
Quick Start
@@ -61,6 +61,7 @@ Mac/Linux
6161
pip install virtualenv
6262
virtualenv <your-env>
6363
source <your-env>/bin/activate
64+
<your-env>/bin/pip install python-spanner-django
6465
<your-env>/bin/pip install google-cloud-spanner
6566
6667
@@ -72,6 +73,7 @@ Windows
7273
pip install virtualenv
7374
virtualenv <your-env>
7475
<your-env>\Scripts\activate
76+
<your-env>\Scripts\pip.exe install python-spanner-django
7577
<your-env>\Scripts\pip.exe install google-cloud-spanner
7678
7779
@@ -171,11 +173,7 @@ Please run:
171173
172174
$ python3 manage.py migrate
173175
174-
175-
and that'll take a while running, but when done, it will look like the following
176-
177-
178-
After this you should can see the tables and indices created in your Cloud Spanner console
176+
and that'll take a while to run. After this you should can see the tables and indices created in your Cloud Spanner console.
179177

180178
Now run your server
181179
~~~~~~~~~~~~~~~~~~~

django_spanner/creation.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from django.db.backends.base.creation import BaseDatabaseCreation
1212
from django.utils.module_loading import import_string
13-
13+
from django.conf import settings
1414

1515
class DatabaseCreation(BaseDatabaseCreation):
1616
"""
@@ -21,8 +21,6 @@ class DatabaseCreation(BaseDatabaseCreation):
2121
def mark_skips(self):
2222
"""Skip tests that don't work on Spanner."""
2323

24-
from django.conf import settings
25-
2624
for test_name in self.connection.features.skip_tests:
2725
test_case_name, _, method_name = test_name.rpartition(".")
2826
test_app = test_name.split(".")[0]

django_spanner/operations.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from django.db.utils import DatabaseError
1515
from django.utils import timezone
1616
from django.utils.duration import duration_microseconds
17+
from django.conf import settings
1718
from google.cloud.spanner_dbapi.parse_utils import (
1819
DateStr,
1920
TimestampStr,
@@ -168,7 +169,6 @@ def adapt_datetimefield_value(self, value):
168169
:rtype: :class:`~google.cloud.spanner_dbapi.types.TimestampStr`
169170
:returns: Formatted Time.
170171
"""
171-
from django.conf import settings
172172

173173
if value is None:
174174
return None
@@ -177,8 +177,6 @@ def adapt_datetimefield_value(self, value):
177177
return value
178178
# Cloud Spanner doesn't support tz-aware datetimes
179179
if timezone.is_aware(value):
180-
from django.conf import settings
181-
182180
if settings.USE_TZ:
183181
value = timezone.make_naive(value, self.connection.timezone)
184182
else:
@@ -304,7 +302,6 @@ def convert_datetimefield_value(self, value, expression, connection):
304302
value.second,
305303
value.microsecond,
306304
)
307-
from django.conf import settings
308305

309306
return (
310307
timezone.make_aware(dt, self.connection.timezone)
@@ -382,7 +379,6 @@ def datetime_extract_sql(self, lookup_type, field_name, tzname):
382379
:rtype: str
383380
:returns: A SQL statement for extracting.
384381
"""
385-
from django.conf import settings
386382

387383
tzname = tzname if settings.USE_TZ else "UTC"
388384
lookup_type = self.extract_names.get(lookup_type, lookup_type)
@@ -448,7 +444,6 @@ def datetime_trunc_sql(self, lookup_type, field_name, tzname):
448444
:rtype: str
449445
:returns: A SQL statement for truncating.
450446
"""
451-
from django.conf import settings
452447

453448
# https://cloud.google.com/spanner/docs/functions-and-operators#timestamp_trunc
454449
tzname = tzname if settings.USE_TZ else "UTC"
@@ -495,7 +490,6 @@ def datetime_cast_date_sql(self, field_name, tzname):
495490
:rtype: str
496491
:returns: A SQL statement for casting.
497492
"""
498-
from django.conf import settings
499493

500494
# https://cloud.google.com/spanner/docs/functions-and-operators#date
501495
tzname = tzname if settings.USE_TZ else "UTC"
@@ -514,7 +508,6 @@ def datetime_cast_time_sql(self, field_name, tzname):
514508
:rtype: str
515509
:returns: A SQL statement for casting.
516510
"""
517-
from django.conf import settings
518511

519512
tzname = tzname if settings.USE_TZ else "UTC"
520513
# Cloud Spanner doesn't have a function for converting

docs/base-spi.rst

Lines changed: 0 additions & 8 deletions
This file was deleted.

docs/compiler-api.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ Compiler API
33

44
.. automodule:: django_spanner.compiler
55
:members:
6-
:inherited-members:
7-
8-
6+
:inherited-members:

docs/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
import sys
2020
import os
2121
import shlex
22+
import django
2223

24+
sys.path.insert(0, os.path.abspath(".."))
25+
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.settings"
26+
django.setup()
2327
# If extensions (or modules to document with autodoc) are in another directory,
2428
# add this directory to sys.path here. If the directory is relative to the
2529
# documentation root, use os.path.abspath to make it absolute, like shown here.

docs/creation-api.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ Creation API
33

44
.. automodule:: django_spanner.creation
55
:members:
6-
:inherited-members:
7-
8-
6+
:inherited-members:

docs/expressions-api.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ Expressions API
33

44
.. automodule:: django_spanner.expressions
55
:members:
6-
:inherited-members:
7-
8-
6+
:inherited-members:

docs/functions-api.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ Functions API
33

44
.. automodule:: django_spanner.functions
55
:members:
6-
:inherited-members:
7-
8-
6+
:inherited-members:

docs/introspection-api.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ Introspection API
33

44
.. automodule:: django_spanner.introspection
55
:members:
6-
:inherited-members:
7-
8-
6+
:inherited-members:

docs/lookups-api.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ Lookups API
33

44
.. automodule:: django_spanner.lookups
55
:members:
6-
:inherited-members:
7-
8-
6+
:inherited-members:

docs/samples.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,4 @@ the following two models:
2121
class Choice(models.Model):
2222
question = models.ForeignKey(Question, on_delete=models.CASCADE)
2323
choice_text = models.CharField(max_length=200)
24-
votes = models.IntegerField(default=0)
25-
26-
24+
votes = models.IntegerField(default=0)

docs/schema-api.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ Schema API
33

44
.. automodule:: django_spanner.schema
55
:members:
6-
:inherited-members:
7-
8-
6+
:inherited-members:

docs/utils-api.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ Utils API
33

44
.. automodule:: django_spanner.utils
55
:members:
6-
:inherited-members:
7-
8-
6+
:inherited-members:

0 commit comments

Comments
 (0)
0