mirror of
https://github.com/django/django.git
synced 2025-08-20 16:59:12 +00:00
Removed double spaces after periods and within phrases.
This commit is contained in:
parent
1909108f9f
commit
1ecf6889ca
@ -223,7 +223,7 @@ FORM_RENDERER = "django.forms.renderers.DjangoTemplates"
|
||||
DEFAULT_FROM_EMAIL = "webmaster@localhost"
|
||||
|
||||
# Subject-line prefix for email messages send with django.core.mail.mail_admins
|
||||
# or ...mail_managers. Make sure to include the trailing space.
|
||||
# or ...mail_managers. Make sure to include the trailing space.
|
||||
EMAIL_SUBJECT_PREFIX = "[Django] "
|
||||
|
||||
# Whether to append trailing slashes to URLs.
|
||||
@ -533,9 +533,8 @@ LOGOUT_REDIRECT_URL = None
|
||||
# The number of seconds a password reset link is valid for (default: 3 days).
|
||||
PASSWORD_RESET_TIMEOUT = 60 * 60 * 24 * 3
|
||||
|
||||
# the first hasher in this list is the preferred algorithm. any
|
||||
# password using different algorithms will be converted automatically
|
||||
# upon login
|
||||
# The first hasher in this list is the preferred algorithm. Any password using
|
||||
# different algorithms will be converted automatically upon login.
|
||||
PASSWORD_HASHERS = [
|
||||
"django.contrib.auth.hashers.PBKDF2PasswordHasher",
|
||||
"django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher",
|
||||
|
@ -1026,7 +1026,7 @@ class ModelAdminChecks(BaseModelAdminChecks):
|
||||
return must_inherit_from(
|
||||
parent="ListFilter", option=label, obj=obj, id="admin.E113"
|
||||
)
|
||||
# ... but not a FieldListFilter.
|
||||
# ... but not a FieldListFilter.
|
||||
elif issubclass(item, FieldListFilter):
|
||||
return [
|
||||
checks.Error(
|
||||
|
@ -250,7 +250,7 @@ class BaseModelAdmin(metaclass=forms.MediaDefiningClass):
|
||||
def get_field_queryset(self, db, db_field, request):
|
||||
"""
|
||||
If the ModelAdmin specifies ordering, the queryset should respect that
|
||||
ordering. Otherwise don't specify the queryset, let the field decide
|
||||
ordering. Otherwise don't specify the queryset, let the field decide
|
||||
(return None in that case).
|
||||
"""
|
||||
try:
|
||||
@ -1047,7 +1047,7 @@ class ModelAdmin(BaseModelAdmin):
|
||||
|
||||
def get_action_choices(self, request, default_choices=models.BLANK_CHOICE_DASH):
|
||||
"""
|
||||
Return a list of choices for use in a form object. Each choice is a
|
||||
Return a list of choices for use in a form object. Each choice is a
|
||||
tuple (name, description).
|
||||
"""
|
||||
choices = [*default_choices]
|
||||
@ -1059,7 +1059,7 @@ class ModelAdmin(BaseModelAdmin):
|
||||
def get_action(self, action):
|
||||
"""
|
||||
Return a given action from a parameter, which can either be a callable,
|
||||
or the name of a method on the ModelAdmin. Return is a tuple of
|
||||
or the name of a method on the ModelAdmin. Return is a tuple of
|
||||
(callable, name, description).
|
||||
"""
|
||||
# If the action is a callable, just use it.
|
||||
|
@ -118,7 +118,7 @@ class AdminSeleniumTestCase(SeleniumTestCase, StaticLiveServerTestCase):
|
||||
|
||||
def wait_page_ready(self, timeout=10):
|
||||
"""
|
||||
Block until the page is ready.
|
||||
Block until the page is ready.
|
||||
"""
|
||||
self.wait_until(
|
||||
lambda driver: driver.execute_script("return document.readyState;")
|
||||
|
@ -30,7 +30,7 @@ def get_view_name(view_func):
|
||||
|
||||
def parse_docstring(docstring):
|
||||
"""
|
||||
Parse out the parts of a docstring. Return (title, body, metadata).
|
||||
Parse out the parts of a docstring. Return (title, body, metadata).
|
||||
"""
|
||||
if not docstring:
|
||||
return "", "", {}
|
||||
|
@ -254,7 +254,7 @@ class RemoteUserBackend(ModelBackend):
|
||||
is handling authentication outside of Django.
|
||||
|
||||
By default, the ``authenticate`` method creates ``User`` objects for
|
||||
usernames that don't already exist in the database. Subclasses can disable
|
||||
usernames that don't already exist in the database. Subclasses can disable
|
||||
this behavior by setting the ``create_unknown_user`` attribute to
|
||||
``False``.
|
||||
"""
|
||||
@ -318,7 +318,7 @@ class RemoteUserBackend(ModelBackend):
|
||||
def clean_username(self, username):
|
||||
"""
|
||||
Perform any cleaning on the "username" prior to using it to get or
|
||||
create the user object. Return the cleaned username.
|
||||
create the user object. Return the cleaned username.
|
||||
|
||||
By default, return the username unchanged.
|
||||
"""
|
||||
|
@ -314,7 +314,7 @@ class PBKDF2PasswordHasher(BasePasswordHasher):
|
||||
Secure password hashing using the PBKDF2 algorithm (recommended)
|
||||
|
||||
Configured to use PBKDF2 + HMAC + SHA256.
|
||||
The result is a 64 byte binary string. Iterations may be changed
|
||||
The result is a 64 byte binary string. Iterations may be changed
|
||||
safely but you must rename the algorithm if you change SHA256.
|
||||
"""
|
||||
|
||||
@ -486,7 +486,7 @@ class BCryptSHA256PasswordHasher(BasePasswordHasher):
|
||||
Secure password hashing using the bcrypt algorithm (recommended)
|
||||
|
||||
This is considered by many to be the most secure algorithm but you
|
||||
must first install the bcrypt library. Please be warned that
|
||||
must first install the bcrypt library. Please be warned that
|
||||
this library depends on native C code and might cause portability
|
||||
issues.
|
||||
"""
|
||||
@ -559,7 +559,7 @@ class BCryptPasswordHasher(BCryptSHA256PasswordHasher):
|
||||
Secure password hashing using the bcrypt algorithm
|
||||
|
||||
This is considered by many to be the most secure algorithm but you
|
||||
must first install the bcrypt library. Please be warned that
|
||||
must first install the bcrypt library. Please be warned that
|
||||
this library depends on native C code and might cause portability
|
||||
issues.
|
||||
|
||||
|
@ -80,7 +80,7 @@ def create_permissions(
|
||||
)
|
||||
|
||||
# Find all the Permissions that have a content_type for a model we're
|
||||
# looking for. We don't need to check for codenames since we already have
|
||||
# looking for. We don't need to check for codenames since we already have
|
||||
# a list of the ones we're going to create.
|
||||
all_perms = set(
|
||||
Permission.objects.using(using)
|
||||
|
@ -137,7 +137,7 @@ class RemoteUserMiddleware:
|
||||
if not hasattr(request, "user"):
|
||||
raise ImproperlyConfigured(
|
||||
"The Django remote user auth middleware requires the"
|
||||
" authentication middleware to be installed. Edit your"
|
||||
" authentication middleware to be installed. Edit your"
|
||||
" MIDDLEWARE setting to insert"
|
||||
" 'django.contrib.auth.middleware.AuthenticationMiddleware'"
|
||||
" before the RemoteUserMiddleware class."
|
||||
@ -166,7 +166,7 @@ class RemoteUserMiddleware:
|
||||
# to authenticate the user.
|
||||
user = auth.authenticate(request, remote_user=username)
|
||||
if user:
|
||||
# User is valid. Set request.user and persist user in the session
|
||||
# User is valid. Set request.user and persist user in the session
|
||||
# by logging the user in.
|
||||
request.user = user
|
||||
auth.login(request, user)
|
||||
@ -194,7 +194,7 @@ class RemoteUserMiddleware:
|
||||
if not hasattr(request, "user"):
|
||||
raise ImproperlyConfigured(
|
||||
"The Django remote user auth middleware requires the"
|
||||
" authentication middleware to be installed. Edit your"
|
||||
" authentication middleware to be installed. Edit your"
|
||||
" MIDDLEWARE setting to insert"
|
||||
" 'django.contrib.auth.middleware.AuthenticationMiddleware'"
|
||||
" before the RemoteUserMiddleware class."
|
||||
@ -226,7 +226,7 @@ class RemoteUserMiddleware:
|
||||
# to authenticate the user.
|
||||
user = await auth.aauthenticate(request, remote_user=username)
|
||||
if user:
|
||||
# User is valid. Set request.user and persist user in the session
|
||||
# User is valid. Set request.user and persist user in the session
|
||||
# by logging the user in.
|
||||
request.user = user
|
||||
await auth.alogin(request, user)
|
||||
|
@ -117,7 +117,7 @@ class BaseSpatialOperations:
|
||||
def get_geom_placeholder(self, f, value, compiler):
|
||||
"""
|
||||
Return the placeholder for the given geometry field with the given
|
||||
value. Depending on the spatial backend, the placeholder may contain a
|
||||
value. Depending on the spatial backend, the placeholder may contain a
|
||||
stored procedure call to the transformation function of the spatial
|
||||
backend.
|
||||
"""
|
||||
|
@ -54,7 +54,7 @@ class OracleSpatialRefSys(models.Model, SpatialRefSysMixin):
|
||||
auth_name = models.CharField(max_length=256)
|
||||
wktext = models.CharField(max_length=2046)
|
||||
# Optional geometry representing the bounds of this coordinate
|
||||
# system. By default, all are NULL in the table.
|
||||
# system. By default, all are NULL in the table.
|
||||
cs_bounds = models.PolygonField(null=True)
|
||||
|
||||
class Meta:
|
||||
|
@ -3,7 +3,7 @@ This module contains the spatial lookup types, and the `get_geo_where_clause`
|
||||
routine for Oracle Spatial.
|
||||
|
||||
Please note that WKT support is broken on the XE version, and thus
|
||||
this backend will not work on such platforms. Specifically, XE lacks
|
||||
this backend will not work on such platforms. Specifically, XE lacks
|
||||
support for an internal JVM, and Java libraries are required to use
|
||||
the WKT constructors.
|
||||
"""
|
||||
@ -95,7 +95,7 @@ class OracleOperations(BaseSpatialOperations, DatabaseOperations):
|
||||
# We want to get SDO Geometries as WKT because it is much easier to
|
||||
# instantiate GEOS proxies from WKT than SDO_GEOMETRY(...) strings.
|
||||
# However, this adversely affects performance (i.e., Java is called
|
||||
# to convert to WKT on every query). If someone wishes to write a
|
||||
# to convert to WKT on every query). If someone wishes to write a
|
||||
# SDO_GEOMETRY(...) parser in Python, let me know =)
|
||||
select = "SDO_UTIL.TO_WKBGEOMETRY(%s)"
|
||||
|
||||
|
@ -37,7 +37,7 @@ class PostGISIntrospection(DatabaseIntrospection):
|
||||
"""
|
||||
The geometry type OID used by PostGIS does not indicate the particular
|
||||
type of field that a geometry column is (e.g., whether it's a
|
||||
PointField or a PolygonField). Thus, this routine queries the PostGIS
|
||||
PointField or a PolygonField). Thus, this routine queries the PostGIS
|
||||
metadata tables to determine the geometry type.
|
||||
"""
|
||||
with self.connection.cursor() as cursor:
|
||||
|
@ -185,7 +185,7 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations):
|
||||
def spatial_version(self):
|
||||
"""Determine the version of the PostGIS library."""
|
||||
# Trying to get the PostGIS version because the function
|
||||
# signatures will depend on the version used. The cost
|
||||
# signatures will depend on the version used. The cost
|
||||
# here is a database query to determine the version, which
|
||||
# can be mitigated by setting `POSTGIS_VERSION` with a 3-tuple
|
||||
# comprising user-supplied values for the major, minor, and
|
||||
@ -267,7 +267,7 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations):
|
||||
|
||||
This is the most complex implementation of the spatial backends due to
|
||||
what is supported on geodetic geometry columns vs. what's available on
|
||||
projected geometry columns. In addition, it has to take into account
|
||||
projected geometry columns. In addition, it has to take into account
|
||||
the geography column type.
|
||||
"""
|
||||
# Getting the distance parameter
|
||||
@ -330,7 +330,7 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations):
|
||||
"""
|
||||
Helper routine for calling PostGIS functions and returning their result.
|
||||
"""
|
||||
# Close out the connection. See #9437.
|
||||
# Close out the connection. See #9437.
|
||||
with self.connection.temporary_connection() as cursor:
|
||||
cursor.execute("SELECT %s()" % func)
|
||||
return cursor.fetchone()[0]
|
||||
|
@ -33,7 +33,7 @@ def get_srid_info(srid, connection):
|
||||
"""
|
||||
Return the units, unit name, and spheroid WKT associated with the
|
||||
given SRID from the `spatial_ref_sys` (or equivalent) spatial database
|
||||
table for the given database connection. These results are cached.
|
||||
table for the given database connection. These results are cached.
|
||||
"""
|
||||
from django.contrib.gis.gdal import SpatialReference
|
||||
|
||||
@ -89,7 +89,7 @@ class BaseSpatialField(Field):
|
||||
Defaults to 4326 (WGS84).
|
||||
|
||||
spatial_index:
|
||||
Indicates whether to create a spatial index. Defaults to True.
|
||||
Indicates whether to create a spatial index. Defaults to True.
|
||||
Set this instead of 'db_index' for geographic fields since index
|
||||
creation is different for geometry columns.
|
||||
"""
|
||||
@ -97,7 +97,7 @@ class BaseSpatialField(Field):
|
||||
# Setting the index flag with the value of the `spatial_index` keyword.
|
||||
self.spatial_index = spatial_index
|
||||
|
||||
# Setting the SRID and getting the units. Unit information must be
|
||||
# Setting the SRID and getting the units. Unit information must be
|
||||
# easily available in the field instance for distance queries.
|
||||
self.srid = srid
|
||||
|
||||
@ -251,16 +251,16 @@ class GeometryField(BaseSpatialField):
|
||||
arguments:
|
||||
|
||||
dim:
|
||||
The number of dimensions for this geometry. Defaults to 2.
|
||||
The number of dimensions for this geometry. Defaults to 2.
|
||||
|
||||
extent:
|
||||
Customize the extent, in a 4-tuple of WGS 84 coordinates, for the
|
||||
geometry field entry in the `USER_SDO_GEOM_METADATA` table. Defaults
|
||||
geometry field entry in the `USER_SDO_GEOM_METADATA` table. Defaults
|
||||
to (-180.0, -90.0, 180.0, 90.0).
|
||||
|
||||
tolerance:
|
||||
Define the tolerance, in meters, to use for the geometry field
|
||||
entry in the `USER_SDO_GEOM_METADATA` table. Defaults to 0.05.
|
||||
entry in the `USER_SDO_GEOM_METADATA` table. Defaults to 0.05.
|
||||
"""
|
||||
# Setting the dimension of the geometry field.
|
||||
self.dim = dim
|
||||
|
@ -35,7 +35,7 @@ class GeoFeedMixin:
|
||||
geom = item.get("geometry")
|
||||
if geom is not None:
|
||||
if isinstance(geom, (list, tuple)):
|
||||
# Special case if a tuple/list was passed in. The tuple may be
|
||||
# Special case if a tuple/list was passed in. The tuple may be
|
||||
# a point or a box
|
||||
box_coords = None
|
||||
if isinstance(geom[0], (list, tuple)):
|
||||
|
@ -9,8 +9,8 @@ from .widgets import OpenLayersWidget
|
||||
|
||||
class GeometryField(forms.Field):
|
||||
"""
|
||||
This is the basic form field for a Geometry. Any textual input that is
|
||||
accepted by GEOSGeometry is accepted by this form. By default,
|
||||
This is the basic form field for a Geometry. Any textual input that is
|
||||
accepted by GEOSGeometry is accepted by this form. By default,
|
||||
this includes WKT, HEXEWKB, WKB (in a buffer), and GeoJSON.
|
||||
"""
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""
|
||||
This module houses ctypes interfaces for GDAL objects. The following GDAL
|
||||
This module houses ctypes interfaces for GDAL objects. The following GDAL
|
||||
objects are supported:
|
||||
|
||||
CoordTransform: Used for coordinate transformations from one spatial
|
||||
|
@ -4,7 +4,7 @@ an interface for reading vector geometry data from many different file
|
||||
formats (including ESRI shapefiles).
|
||||
|
||||
When instantiating a DataSource object, use the filename of a
|
||||
GDAL-supported data source. For example, a SHP file or a
|
||||
GDAL-supported data source. For example, an SHP file or a
|
||||
TIGER/Line file from the government.
|
||||
|
||||
The ds_driver keyword is used internally when a ctypes pointer
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""
|
||||
The GDAL/OGR library uses an Envelope structure to hold the bounding
|
||||
box information for a geometry. The envelope (bounding box) contains
|
||||
box information for a geometry. The envelope (bounding box) contains
|
||||
two pairs of coordinates, one for the lower left coordinate and one
|
||||
for the upper right coordinate:
|
||||
|
||||
@ -17,8 +17,8 @@ from django.contrib.gis.gdal.error import GDALException
|
||||
|
||||
|
||||
# The OGR definition of an Envelope is a C structure containing four doubles.
|
||||
# See the 'ogr_core.h' source file for more information:
|
||||
# https://gdal.org/doxygen/ogr__core_8h_source.html
|
||||
# See the 'ogr_core.h' source file for more information:
|
||||
# https://gdal.org/doxygen/ogr__core_8h_source.html
|
||||
class OGREnvelope(Structure):
|
||||
"Represent the OGREnvelope C Structure."
|
||||
|
||||
@ -33,7 +33,7 @@ class OGREnvelope(Structure):
|
||||
class Envelope:
|
||||
"""
|
||||
The Envelope object is a C structure that contains the minimum and
|
||||
maximum X, Y coordinates for a rectangle bounding box. The naming
|
||||
maximum X, Y coordinates for a rectangle bounding box. The naming
|
||||
of the variables is compatible with the OGR Envelope structure.
|
||||
"""
|
||||
|
||||
|
@ -8,7 +8,7 @@ from django.utils.encoding import force_bytes, force_str
|
||||
|
||||
|
||||
# For more information, see the OGR C API source code:
|
||||
# https://gdal.org/api/vector_c_api.html
|
||||
# https://gdal.org/api/vector_c_api.html
|
||||
#
|
||||
# The OGR_F_* routines are relevant here.
|
||||
class Feature(GDALBase):
|
||||
@ -31,7 +31,7 @@ class Feature(GDALBase):
|
||||
def __getitem__(self, index):
|
||||
"""
|
||||
Get the Field object at the specified index, which may be either
|
||||
an integer or the Field's string label. Note that the Field object
|
||||
an integer or the Field's string label. Note that the Field object
|
||||
is not the field's _value_ -- use the `get` method instead to
|
||||
retrieve the value (e.g. an integer) instead of a Field instance.
|
||||
"""
|
||||
@ -106,7 +106,7 @@ class Feature(GDALBase):
|
||||
def get(self, field):
|
||||
"""
|
||||
Return the value of the field, instead of an instance of the Field
|
||||
object. May take a string of the field name or a Field object as
|
||||
object. May take a string of the field name or a Field object as
|
||||
parameters.
|
||||
"""
|
||||
field_name = getattr(field, "name", field)
|
||||
|
@ -8,7 +8,7 @@ from django.utils.encoding import force_str
|
||||
|
||||
|
||||
# For more information, see the OGR C API source code:
|
||||
# https://gdal.org/api/vector_c_api.html
|
||||
# https://gdal.org/api/vector_c_api.html
|
||||
#
|
||||
# The OGR_Fld_* routines are relevant here.
|
||||
class Field(GDALBase):
|
||||
|
@ -5,7 +5,7 @@ OGRGeometry may be instantiated when reading geometries from OGR Data Sources
|
||||
(e.g. SHP files), or when given OGC WKT (a string).
|
||||
|
||||
While the 'full' API is not present yet, the API is "pythonic" unlike
|
||||
the traditional and "next-generation" OGR Python bindings. One major
|
||||
the traditional and "next-generation" OGR Python bindings. One major
|
||||
advantage OGR Geometries have over their GEOS counterparts is support
|
||||
for spatial reference systems and their transformation.
|
||||
|
||||
@ -454,7 +454,7 @@ class OGRGeometry(GDALBase):
|
||||
"""
|
||||
Transform this geometry to a different spatial reference system.
|
||||
May take a CoordTransform object, a SpatialReference object, string
|
||||
WKT or PROJ, and/or an integer SRID. By default, return nothing
|
||||
WKT or PROJ, and/or an integer SRID. By default, return nothing
|
||||
and transform the geometry in-place. However, if the `clone` keyword is
|
||||
set, return a transformed clone of this geometry.
|
||||
"""
|
||||
|
@ -27,8 +27,8 @@ class Layer(GDALBase):
|
||||
def __init__(self, layer_ptr, ds):
|
||||
"""
|
||||
Initialize on an OGR C pointer to the Layer and the `DataSource` object
|
||||
that owns this layer. The `DataSource` object is required so that a
|
||||
reference to it is kept with this Layer. This prevents garbage
|
||||
that owns this layer. The `DataSource` object is required so that a
|
||||
reference to it is kept with this Layer. This prevents garbage
|
||||
collection of the `DataSource` while this Layer is still active.
|
||||
"""
|
||||
if not layer_ptr:
|
||||
@ -75,7 +75,7 @@ class Layer(GDALBase):
|
||||
def _make_feature(self, feat_id):
|
||||
"""
|
||||
Helper routine for __getitem__ that constructs a Feature from the given
|
||||
Feature ID. If the OGR Layer does not support random-access reading,
|
||||
Feature ID. If the OGR Layer does not support random-access reading,
|
||||
then each feature of the layer will be incremented through until the
|
||||
a Feature is found matching the given feature ID.
|
||||
"""
|
||||
@ -150,7 +150,7 @@ class Layer(GDALBase):
|
||||
@property
|
||||
def field_types(self):
|
||||
"""
|
||||
Return a list of the types of fields in this Layer. For example,
|
||||
Return a list of the types of fields in this Layer. For example,
|
||||
return the list [OFTInteger, OFTReal, OFTString] for an OGR layer that
|
||||
has an integer, a floating-point, and string fields.
|
||||
"""
|
||||
@ -226,7 +226,7 @@ class Layer(GDALBase):
|
||||
def test_capability(self, capability):
|
||||
"""
|
||||
Return a bool indicating whether the this Layer supports the given
|
||||
capability (a string). Valid capability strings include:
|
||||
capability (a string). Valid capability strings include:
|
||||
'RandomRead', 'SequentialWrite', 'RandomWrite', 'FastSpatialFilter',
|
||||
'FastFeatureCount', 'FastGetExtent', 'CreateField', 'Transactions',
|
||||
'DeleteFeature', and 'FastSetNextByIndex'.
|
||||
|
@ -52,7 +52,7 @@ elif os.name == "posix":
|
||||
else:
|
||||
raise ImproperlyConfigured('GDAL is unsupported on OS "%s".' % os.name)
|
||||
|
||||
# Using the ctypes `find_library` utility to find the
|
||||
# Using the ctypes `find_library` utility to find the
|
||||
# path to the GDAL library from the list of library names.
|
||||
if lib_names:
|
||||
for lib_name in lib_names:
|
||||
@ -71,7 +71,7 @@ if lib_path is None:
|
||||
lgdal = CDLL(lib_path)
|
||||
|
||||
# On Windows, the GDAL binaries have some OSR routines exported with
|
||||
# STDCALL, while others are not. Thus, the library will also need to
|
||||
# STDCALL, while others are not. Thus, the library will also need to
|
||||
# be loaded up as WinDLL for said OSR functions that require the
|
||||
# different calling convention.
|
||||
if os.name == "nt":
|
||||
|
@ -37,9 +37,9 @@ def check_const_string(result, func, cargs, offset=None, cpl=False):
|
||||
def check_string(result, func, cargs, offset=-1, str_result=False):
|
||||
"""
|
||||
Check the string output returned from the given function, and free
|
||||
the string pointer allocated by OGR. The `str_result` keyword
|
||||
the string pointer allocated by OGR. The `str_result` keyword
|
||||
may be used when the result is the string pointer, otherwise
|
||||
the OGR error code is assumed. The `offset` keyword may be used
|
||||
the OGR error code is assumed. The `offset` keyword may be used
|
||||
to extract the string pointer passed in by-reference at the given
|
||||
slice offset in the function arguments.
|
||||
"""
|
||||
@ -134,7 +134,7 @@ def check_pointer(result, func, cargs):
|
||||
def check_str_arg(result, func, cargs):
|
||||
"""
|
||||
This is for the OSRGet[Angular|Linear]Units functions, which
|
||||
require that the returned string pointer not be freed. This
|
||||
require that the returned string pointer not be freed. This
|
||||
returns both the double and string values.
|
||||
"""
|
||||
dbl = result
|
||||
|
@ -113,8 +113,8 @@ class SpatialReference(GDALBase):
|
||||
def __getitem__(self, target):
|
||||
"""
|
||||
Return the value of the given string attribute node, None if the node
|
||||
doesn't exist. Can also take a tuple as a parameter, (target, child),
|
||||
where child is the index of the attribute in the WKT. For example:
|
||||
doesn't exist. Can also take a tuple as a parameter, (target, child),
|
||||
where child is the index of the attribute in the WKT. For example:
|
||||
|
||||
>>> wkt = 'GEOGCS["WGS 84", DATUM["WGS_1984, ... AUTHORITY["EPSG","4326"]]'
|
||||
>>> srs = SpatialReference(wkt) # could also use 'WGS84', or 4326
|
||||
|
@ -81,7 +81,7 @@ class GeoIP2:
|
||||
* cache: The cache settings when opening up the GeoIP datasets. May be
|
||||
an integer in (0, 1, 2, 4, 8) corresponding to the MODE_AUTO,
|
||||
MODE_MMAP_EXT, MODE_MMAP, MODE_FILE, and MODE_MEMORY,
|
||||
`GeoIPOptions` C API settings, respectively. Defaults to 0,
|
||||
`GeoIPOptions` C API settings, respectively. Defaults to 0,
|
||||
meaning MODE_AUTO.
|
||||
|
||||
* country: The name of the GeoIP country data file. Defaults to
|
||||
|
@ -2,7 +2,7 @@ import re
|
||||
|
||||
from django.utils.regex_helper import _lazy_re_compile
|
||||
|
||||
# Regular expression for recognizing HEXEWKB and WKT. A prophylactic measure
|
||||
# Regular expression for recognizing HEXEWKB and WKT. A prophylactic measure
|
||||
# to prevent potentially malicious input from reaching the underlying C
|
||||
# library. Not a substitute for good web security programming practices.
|
||||
hex_regex = _lazy_re_compile(r"^[0-9A-F]+$", re.I)
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""
|
||||
The GeoDjango GEOS module. Please consult the GeoDjango documentation
|
||||
The GeoDjango GEOS module. Please consult the GeoDjango documentation
|
||||
for more details: https://docs.djangoproject.com/en/dev/ref/contrib/gis/geos/
|
||||
"""
|
||||
|
||||
|
@ -609,7 +609,7 @@ class GEOSGeometryBase(GEOSBase):
|
||||
def simplify(self, tolerance=0.0, preserve_topology=False):
|
||||
"""
|
||||
Return the Geometry, simplified using the Douglas-Peucker algorithm
|
||||
to the specified tolerance (higher tolerance => less points). If no
|
||||
to the specified tolerance (higher tolerance => less points). If no
|
||||
tolerance provided, defaults to 0.
|
||||
|
||||
By default, don't preserve topology - e.g. polygons can be split,
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""
|
||||
Module that holds classes for performing I/O operations on GEOS geometry
|
||||
objects. Specifically, this has Python implementations of WKB/WKT
|
||||
objects. Specifically, this has Python implementations of WKB/WKT
|
||||
reader and writer classes.
|
||||
"""
|
||||
|
||||
|
@ -41,7 +41,7 @@ def load_geos():
|
||||
raise ImportError('Unsupported OS "%s"' % os.name)
|
||||
|
||||
# Using the ctypes `find_library` utility to find the path to the GEOS
|
||||
# shared library. This is better than manually specifying each library name
|
||||
# shared library. This is better than manually specifying each library name
|
||||
# and extension (e.g., libgeos_c.[so|so.1|dylib].).
|
||||
if lib_names:
|
||||
for lib_name in lib_names:
|
||||
@ -55,13 +55,13 @@ def load_geos():
|
||||
'Could not find the GEOS library (tried "%s"). '
|
||||
"Try setting GEOS_LIBRARY_PATH in your settings." % '", "'.join(lib_names)
|
||||
)
|
||||
# Getting the GEOS C library. The C interface (CDLL) is used for
|
||||
# Getting the GEOS C library. The C interface (CDLL) is used for
|
||||
# both *NIX and Windows.
|
||||
# See the GEOS C API source code for more details on the library function calls:
|
||||
# https://libgeos.org/doxygen/geos__c_8h_source.html
|
||||
_lgeos = CDLL(lib_path)
|
||||
# Here we set up the prototypes for the initGEOS_r and finishGEOS_r
|
||||
# routines. These functions aren't actually called until they are
|
||||
# routines. These functions aren't actually called until they are
|
||||
# attached to a GEOS context handle -- this actually occurs in
|
||||
# geos/prototypes/threadsafe.py.
|
||||
_lgeos.initGEOS_r.restype = CONTEXT_PTR
|
||||
|
@ -14,7 +14,7 @@ class LineString(LinearGeometryMixin, GEOSGeometry):
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""
|
||||
Initialize on the given sequence -- may take lists, tuples, NumPy arrays
|
||||
of X,Y pairs, or Point objects. If Point objects are used, ownership is
|
||||
of X,Y pairs, or Point objects. If Point objects are used, ownership is
|
||||
_not_ transferred to the LineString object.
|
||||
|
||||
Examples:
|
||||
|
@ -127,7 +127,7 @@ class Polygon(GEOSGeometry):
|
||||
def _get_single_internal(self, index):
|
||||
"""
|
||||
Return the ring at the specified index. The first index, 0, will
|
||||
always return the exterior ring. Indices > 0 will return the
|
||||
always return the exterior ring. Indices > 0 will return the
|
||||
interior ring at the given index (e.g., poly[1] and poly[2] would
|
||||
return the first and second interior ring, respectively).
|
||||
|
||||
|
@ -14,7 +14,7 @@ c_uchar_p = POINTER(c_ubyte)
|
||||
# We create a simple subclass of c_char_p here because when the response
|
||||
# type is set to c_char_p, you get a _Python_ string and there's no way
|
||||
# to access the string's address inside the error checking function.
|
||||
# In other words, you can't free the memory allocated inside GEOS. Previously,
|
||||
# In other words, you can't free the memory allocated inside GEOS. Previously,
|
||||
# the return type would just be omitted and the integer address would be
|
||||
# used -- but this allows us to be specific in the function definition and
|
||||
# keeps the reference so it may be free'd.
|
||||
|
@ -82,7 +82,7 @@ wkb_reader_destroy = GEOSFuncFactory("GEOSWKBReader_destroy", argtypes=[WKB_READ
|
||||
class WKBReadFunc(GEOSFuncFactory):
|
||||
# Although the function definitions take `const unsigned char *`
|
||||
# as their parameter, we use c_char_p here so the function may
|
||||
# take Python strings directly as parameters. Inside Python there
|
||||
# take Python strings directly as parameters. Inside Python there
|
||||
# is not a difference between signed and unsigned characters, so
|
||||
# it is not a problem.
|
||||
argtypes = [WKB_READ_PTR, c_char_p, c_size_t]
|
||||
@ -318,7 +318,7 @@ class WKBWriter(IOBase):
|
||||
|
||||
|
||||
# `ThreadLocalIO` object holds instances of the WKT and WKB reader/writer
|
||||
# objects that are local to the thread. The `GEOSGeometry` internals
|
||||
# objects that are local to the thread. The `GEOSGeometry` internals
|
||||
# access these instances by calling the module-level functions, defined
|
||||
# below.
|
||||
class ThreadLocalIO(threading.local):
|
||||
|
@ -18,7 +18,7 @@ def kml(request, label, model, field_name=None, compress=False, using=DEFAULT_DB
|
||||
klass = apps.get_model(label, model)
|
||||
except LookupError:
|
||||
raise Http404(
|
||||
'You must supply a valid app label and module name. Got "%s.%s"'
|
||||
'You must supply a valid app label and module name. Got "%s.%s"'
|
||||
% (label, model)
|
||||
)
|
||||
|
||||
|
@ -109,7 +109,7 @@ class LayerMapping:
|
||||
"""
|
||||
A LayerMapping object is initialized using the given Model (not an instance),
|
||||
a DataSource (or string path to an OGR-supported data file), and a mapping
|
||||
dictionary. See the module level docstring for more details and keyword
|
||||
dictionary. See the module level docstring for more details and keyword
|
||||
argument usage.
|
||||
"""
|
||||
# Getting the DataSource and the associated Layer.
|
||||
@ -195,7 +195,7 @@ class LayerMapping:
|
||||
need to increment through each feature in the Layer.
|
||||
"""
|
||||
# The geometry field of the model is set here.
|
||||
# TODO: Support more than one geometry field / model. However, this
|
||||
# TODO: Support more than one geometry field / model. However, this
|
||||
# depends on the GDAL Driver in use.
|
||||
self.geom_field = False
|
||||
self.fields = {}
|
||||
@ -263,7 +263,7 @@ class LayerMapping:
|
||||
)
|
||||
|
||||
# Setting the `geom_field` attribute w/the name of the model field
|
||||
# that is a Geometry. Also setting the coordinate dimension
|
||||
# that is a Geometry. Also setting the coordinate dimension
|
||||
# attribute.
|
||||
self.geom_field = field_name
|
||||
self.coord_dim = coord_dim
|
||||
@ -570,7 +570,7 @@ class LayerMapping:
|
||||
|
||||
fid_range:
|
||||
May be set with a slice or tuple of (begin, end) feature ID's to map
|
||||
from the data source. In other words, this keyword enables the user
|
||||
from the data source. In other words, this keyword enables the user
|
||||
to selectively import a subset range of features in the geographic
|
||||
data source.
|
||||
|
||||
@ -581,13 +581,13 @@ class LayerMapping:
|
||||
|
||||
progress:
|
||||
When this keyword is set, status information will be printed giving
|
||||
the number of features processed and successfully saved. By default,
|
||||
the number of features processed and successfully saved. By default,
|
||||
progress information will pe printed every 1000 features processed,
|
||||
however, this default may be overridden by setting this keyword with an
|
||||
integer for the desired interval.
|
||||
|
||||
stream:
|
||||
Status information will be written to this file handle. Defaults to
|
||||
Status information will be written to this file handle. Defaults to
|
||||
using `sys.stdout`, but any object with a `write` method is supported.
|
||||
|
||||
silent:
|
||||
@ -596,7 +596,7 @@ class LayerMapping:
|
||||
|
||||
strict:
|
||||
Execution of the model mapping will cease upon the first error
|
||||
encountered. The default behavior is to attempt to continue.
|
||||
encountered. The default behavior is to attempt to continue.
|
||||
"""
|
||||
# Getting the default Feature ID range.
|
||||
default_range = self.check_fid_range(fid_range)
|
||||
|
@ -25,7 +25,7 @@ def mapping(data_source, geom_name="geom", layer_key=0, multi_geom=False):
|
||||
`geom_name` => The name of the geometry field to use for the model.
|
||||
|
||||
`layer_key` => The key for specifying which layer in the DataSource to use;
|
||||
defaults to 0 (the first layer). May be an integer index or a string
|
||||
defaults to 0 (the first layer). May be an integer index or a string
|
||||
identifier for the layer.
|
||||
|
||||
`multi_geom` => Boolean (default: False) - specify as multigeometry.
|
||||
@ -91,10 +91,10 @@ def ogrinspect(*args, **kwargs):
|
||||
Otherwise will default to `geom`
|
||||
|
||||
`layer_key` => The key for specifying which layer in the DataSource to use;
|
||||
defaults to 0 (the first layer). May be an integer index or a string
|
||||
defaults to 0 (the first layer). May be an integer index or a string
|
||||
identifier for the layer.
|
||||
|
||||
`srid` => The SRID to use for the Geometry Field. If it can be determined,
|
||||
`srid` => The SRID to use for the Geometry Field. If it can be determined,
|
||||
the SRID of the datasource is used.
|
||||
|
||||
`multi_geom` => Boolean (default: False) - specify as multigeometry.
|
||||
@ -107,18 +107,18 @@ def ogrinspect(*args, **kwargs):
|
||||
autogenerated models thus avoiding duplicated imports when building
|
||||
more than one model by batching ogrinspect()
|
||||
|
||||
`decimal` => Boolean or sequence (default: False). When set to True
|
||||
`decimal` => Boolean or sequence (default: False). When set to True
|
||||
all generated model fields corresponding to the `OFTReal` type will
|
||||
be `DecimalField` instead of `FloatField`. A sequence of specific
|
||||
be `DecimalField` instead of `FloatField`. A sequence of specific
|
||||
field names to generate as `DecimalField` may also be used.
|
||||
|
||||
`blank` => Boolean or sequence (default: False). When set to True all
|
||||
generated model fields will have `blank=True`. If the user wants to
|
||||
`blank` => Boolean or sequence (default: False). When set to True all
|
||||
generated model fields will have `blank=True`. If the user wants to
|
||||
give specific fields to have blank, then a list/tuple of OGR field
|
||||
names may be used.
|
||||
|
||||
`null` => Boolean (default: False) - When set to True all generated
|
||||
model fields will have `null=True`. If the user wants to specify
|
||||
model fields will have `null=True`. If the user wants to specify
|
||||
give specific fields to have null, then a list/tuple of OGR field
|
||||
names may be used.
|
||||
|
||||
@ -142,7 +142,7 @@ def _ogrinspect(
|
||||
):
|
||||
"""
|
||||
Helper routine for `ogrinspect` that generates GeoDjango models corresponding
|
||||
to the given data source. See the `ogrinspect` docstring for more details.
|
||||
to the given data source. See the `ogrinspect` docstring for more details.
|
||||
"""
|
||||
# Getting the DataSource
|
||||
if isinstance(data_source, str):
|
||||
|
@ -8,7 +8,7 @@ def add_srs_entry(
|
||||
"""
|
||||
Take a GDAL SpatialReference system and add its information to the
|
||||
`spatial_ref_sys` table of the spatial backend. Doing this enables
|
||||
database-level spatial transformations for the backend. Thus, this utility
|
||||
database-level spatial transformations for the backend. Thus, this utility
|
||||
is useful for adding spatial reference systems not included by default with
|
||||
the backend:
|
||||
|
||||
|
@ -130,7 +130,7 @@ class SessionStore(SessionBase):
|
||||
session_file_name = self._key_to_file()
|
||||
|
||||
try:
|
||||
# Make sure the file exists. If it does not already exist, an
|
||||
# Make sure the file exists. If it does not already exist, an
|
||||
# empty placeholder file is created.
|
||||
flags = os.O_WRONLY | getattr(os, "O_BINARY", 0)
|
||||
if must_create:
|
||||
@ -145,7 +145,7 @@ class SessionStore(SessionBase):
|
||||
raise CreateError
|
||||
|
||||
# Write the session file without interfering with other threads
|
||||
# or processes. By writing to an atomically generated temporary
|
||||
# or processes. By writing to an atomically generated temporary
|
||||
# file and then using the atomic os.rename() to make the complete
|
||||
# file visible, we avoid having to lock the session file, while
|
||||
# still maintaining its integrity.
|
||||
@ -153,7 +153,7 @@ class SessionStore(SessionBase):
|
||||
# Note: Locking the session file was explored, but rejected in part
|
||||
# because in order to be atomic and cross-platform, it required a
|
||||
# long-lived lock file for each session, doubling the number of
|
||||
# files in the session storage directory at any given time. This
|
||||
# files in the session storage directory at any given time. This
|
||||
# rename solution is cleaner and avoids any additional overhead
|
||||
# when reading the session data, which is the more common case
|
||||
# unless SESSION_SAVE_EVERY_REQUEST = True.
|
||||
|
2
django/core/cache/__init__.py
vendored
2
django/core/cache/__init__.py
vendored
@ -3,7 +3,7 @@ Caching framework.
|
||||
|
||||
This package defines set of cache backends that all conform to a simple API.
|
||||
In a nutshell, a cache is a set of values -- which can be any object that
|
||||
may be pickled -- identified by string keys. For the complete API, see
|
||||
may be pickled -- identified by string keys. For the complete API, see
|
||||
the abstract BaseCache class in django.core.cache.backends.base.
|
||||
|
||||
Client code should use the `cache` variable defined here to access the default
|
||||
|
2
django/core/cache/backends/base.py
vendored
2
django/core/cache/backends/base.py
vendored
@ -303,7 +303,7 @@ class BaseCache:
|
||||
def set_many(self, data, timeout=DEFAULT_TIMEOUT, version=None):
|
||||
"""
|
||||
Set a bunch of values in the cache at once from a dict of key/value
|
||||
pairs. For certain backends (memcached), this is much more efficient
|
||||
pairs. For certain backends (memcached), this is much more efficient
|
||||
than calling set() multiple times.
|
||||
|
||||
If timeout is given, use that timeout for the key; otherwise use the
|
||||
|
@ -34,7 +34,7 @@ class ImageFile(File):
|
||||
|
||||
def get_image_dimensions(file_or_path, close=False):
|
||||
"""
|
||||
Return the (width, height) of an image, given an open file or a path. Set
|
||||
Return the (width, height) of an image, given an open file or a path. Set
|
||||
'close' to True to close the file at the end if it is initially in an open
|
||||
state.
|
||||
"""
|
||||
|
@ -84,7 +84,7 @@ def file_move_safe(
|
||||
os.remove(old_file_name)
|
||||
except PermissionError as e:
|
||||
# Certain operating systems (Cygwin and Windows)
|
||||
# fail when deleting opened files, ignore it. (For the
|
||||
# fail when deleting opened files, ignore it. (For the
|
||||
# systems where this happens, temporary files will be auto-deleted
|
||||
# on close anyway.)
|
||||
if getattr(e, "winerror", 0) != 32:
|
||||
|
@ -26,7 +26,7 @@ def validate_file_name(name, allow_relative_path=False):
|
||||
class FileProxyMixin:
|
||||
"""
|
||||
A mixin class used to forward file methods to an underlying file
|
||||
object. The internal file object has to be called "file"::
|
||||
object. The internal file object has to be called "file"::
|
||||
|
||||
class FileProxy(FileProxyMixin):
|
||||
def __init__(self, file):
|
||||
|
@ -214,7 +214,7 @@ class BaseCommand:
|
||||
SQL statements, will be wrapped in ``BEGIN`` and ``COMMIT``.
|
||||
|
||||
4. If ``handle()`` or ``execute()`` raised any exception (e.g.
|
||||
``CommandError``), ``run_from_argv()`` will instead print an error
|
||||
``CommandError``), ``run_from_argv()`` will instead print an error
|
||||
message to ``stderr``.
|
||||
|
||||
Thus, the ``handle()`` method is typically the starting point for
|
||||
|
@ -297,7 +297,7 @@ class Command(BaseCommand):
|
||||
nargs="?",
|
||||
help=(
|
||||
"Controls '#: filename:line' lines. If the option is 'full' "
|
||||
"(the default if not given), the lines include both file name "
|
||||
"(the default if not given), the lines include both file name "
|
||||
"and line number. If it's 'file', the line number is omitted. If "
|
||||
"it's 'never', the lines are suppressed (same as --no-location). "
|
||||
"--add-location requires gettext 0.19 or newer."
|
||||
|
@ -199,7 +199,7 @@ def sort_dependencies(app_list, allow_cycles=False):
|
||||
if hasattr(rel_model, "natural_key") and rel_model != model:
|
||||
deps.append(rel_model)
|
||||
# Also add a dependency for any simple M2M relation with a model
|
||||
# that defines a natural key. M2M relations with explicit through
|
||||
# that defines a natural key. M2M relations with explicit through
|
||||
# models don't count as dependencies.
|
||||
for field in model._meta.many_to_many:
|
||||
if field.remote_field.through._meta.auto_created:
|
||||
|
@ -309,7 +309,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
# these are set in single statement it isn't clear what is supposed
|
||||
# to happen.
|
||||
cursor.execute("ALTER SESSION SET NLS_TERRITORY = 'AMERICA'")
|
||||
# Set Oracle date to ANSI date format. This only needs to execute
|
||||
# Set Oracle date to ANSI date format. This only needs to execute
|
||||
# once when we create a new connection. We also set the Territory
|
||||
# to 'AMERICA' which forces Sunday to evaluate to a '1' in
|
||||
# TO_CHAR().
|
||||
@ -578,8 +578,8 @@ class FormatStylePlaceholderCursor:
|
||||
return [p.force_bytes for p in params]
|
||||
|
||||
def _fix_for_params(self, query, params, unify_by_values=False):
|
||||
# oracledb wants no trailing ';' for SQL statements. For PL/SQL, it
|
||||
# it does want a trailing ';' but not a trailing '/'. However, these
|
||||
# oracledb wants no trailing ';' for SQL statements. For PL/SQL, it
|
||||
# does want a trailing ';' but not a trailing '/'. However, these
|
||||
# characters must be included in the original query in case the query
|
||||
# is being passed to SQL*Plus.
|
||||
if query.endswith(";") or query.endswith("/"):
|
||||
|
@ -372,7 +372,7 @@ END;
|
||||
return value.read()
|
||||
|
||||
def quote_name(self, name):
|
||||
# SQL92 requires delimited (quoted) names to be case-sensitive. When
|
||||
# SQL92 requires delimited (quoted) names to be case-sensitive. When
|
||||
# not quoted, Oracle has case-insensitive behavior for identifiers, but
|
||||
# always defaults to uppercase.
|
||||
# We simplify things by making Oracle identifiers always uppercase.
|
||||
|
@ -115,7 +115,7 @@ class Collector:
|
||||
|
||||
def add(self, objs, source=None, nullable=False, reverse_dependency=False):
|
||||
"""
|
||||
Add 'objs' to the collection of objects to be deleted. If the call is
|
||||
Add 'objs' to the collection of objects to be deleted. If the call is
|
||||
the result of a cascade, 'source' should be the model that caused it,
|
||||
and 'nullable' should be set to True if the relation can be null.
|
||||
|
||||
@ -254,8 +254,8 @@ class Collector:
|
||||
):
|
||||
"""
|
||||
Add 'objs' to the collection of objects to be deleted as well as all
|
||||
parent instances. 'objs' must be a homogeneous iterable collection of
|
||||
model instances (e.g. a QuerySet). If 'collect_related' is True,
|
||||
parent instances. 'objs' must be a homogeneous iterable collection of
|
||||
model instances (e.g. a QuerySet). If 'collect_related' is True,
|
||||
related objects will be handled by their respective on_delete handler.
|
||||
|
||||
If the call is the result of a cascade, 'source' should be the model
|
||||
|
@ -388,10 +388,10 @@ class ImageFileDescriptor(FileDescriptor):
|
||||
|
||||
# To prevent recalculating image dimensions when we are instantiating
|
||||
# an object from the database (bug #11084), only update dimensions if
|
||||
# the field had a value before this assignment. Since the default
|
||||
# the field had a value before this assignment. Since the default
|
||||
# value for FileField subclasses is an instance of field.attr_class,
|
||||
# previous_file will only be None when we are called from
|
||||
# Model.__init__(). The ImageField.update_dimension_fields method
|
||||
# Model.__init__(). The ImageField.update_dimension_fields method
|
||||
# hooked up to the post_init signal handles the Model.__init__() cases.
|
||||
# Assignment happening outside of Model.__init__() will trigger the
|
||||
# update right here.
|
||||
@ -476,8 +476,8 @@ class ImageField(FileField):
|
||||
Update field's width and height fields, if defined.
|
||||
|
||||
This method is hooked up to model's post_init signal to update
|
||||
dimensions after instantiating a model instance. However, dimensions
|
||||
won't be updated if the dimensions fields are already populated. This
|
||||
dimensions after instantiating a model instance. However, dimensions
|
||||
won't be updated if the dimensions fields are already populated. This
|
||||
avoids unnecessary recalculation when loading an object from the
|
||||
database.
|
||||
|
||||
@ -505,9 +505,9 @@ class ImageField(FileField):
|
||||
)
|
||||
# When both dimension fields have values, we are most likely loading
|
||||
# data from the database or updating an image field that already had
|
||||
# an image stored. In the first case, we don't want to update the
|
||||
# an image stored. In the first case, we don't want to update the
|
||||
# dimension fields because we are already getting their values from the
|
||||
# database. In the second case, we do want to update the dimensions
|
||||
# database. In the second case, we do want to update the dimensions
|
||||
# fields and will skip this return because force will be True since we
|
||||
# were called from ImageFileDescriptor.__set__.
|
||||
if dimension_fields_filled and not force:
|
||||
|
@ -2326,7 +2326,7 @@ def prefetch_related_objects(model_instances, *related_lookups):
|
||||
return # nothing to do
|
||||
|
||||
# We need to be able to dynamically add to the list of prefetch_related
|
||||
# lookups that we look up (see below). So we need some book keeping to
|
||||
# lookups that we look up (see below). So we need some book keeping to
|
||||
# ensure we don't do duplicate work.
|
||||
done_queries = {} # dictionary of things like 'foo__bar': [results]
|
||||
|
||||
|
@ -232,7 +232,7 @@ class HttpRequest:
|
||||
"""
|
||||
Attempt to return a signed cookie. If the signature fails or the
|
||||
cookie has expired, raise an exception, unless the `default` argument
|
||||
is provided, in which case return that value.
|
||||
is provided, in which case return that value.
|
||||
"""
|
||||
try:
|
||||
cookie_value = self.COOKIES[key]
|
||||
|
@ -100,7 +100,7 @@ def get_token(request):
|
||||
|
||||
A side effect of calling this function is to make the csrf_protect
|
||||
decorator and the CsrfViewMiddleware add a CSRF cookie and a 'Vary: Cookie'
|
||||
header to the outgoing response. For this reason, you may need to use this
|
||||
header to the outgoing response. For this reason, you may need to use this
|
||||
function lazily, as is done by the csrf context processor.
|
||||
"""
|
||||
if "CSRF_COOKIE" in request.META:
|
||||
@ -201,7 +201,7 @@ class CsrfViewMiddleware(MiddlewareMixin):
|
||||
# requires_csrf_token decorator.
|
||||
def _accept(self, request):
|
||||
# Avoid checking the request twice by adding a custom attribute to
|
||||
# request. This will be relevant when both decorator and middleware
|
||||
# request. This will be relevant when both decorator and middleware
|
||||
# are used.
|
||||
request.csrf_processing_done = True
|
||||
return None
|
||||
|
@ -87,7 +87,7 @@ class CsrfTokenNode(Node):
|
||||
if settings.DEBUG:
|
||||
warnings.warn(
|
||||
"A {% csrf_token %} was used in a template, but the context "
|
||||
"did not provide the value. This is usually caused by not "
|
||||
"did not provide the value. This is usually caused by not "
|
||||
"using RequestContext."
|
||||
)
|
||||
return ""
|
||||
@ -205,7 +205,7 @@ class ForNode(Node):
|
||||
values = reversed(values)
|
||||
num_loopvars = len(self.loopvars)
|
||||
unpack = num_loopvars > 1
|
||||
# Create a forloop value in the context. We'll update counters on each
|
||||
# Create a forloop value in the context. We'll update counters on each
|
||||
# iteration just below.
|
||||
loop_dict = context["forloop"] = {
|
||||
"parentloop": parentloop,
|
||||
@ -720,7 +720,7 @@ def do_filter(parser, token):
|
||||
filter_name = getattr(func, "_filter_name", None)
|
||||
if filter_name in ("escape", "safe"):
|
||||
raise TemplateSyntaxError(
|
||||
'"filter %s" is not permitted. Use the "autoescape" tag instead.'
|
||||
'"filter %s" is not permitted. Use the "autoescape" tag instead.'
|
||||
% filter_name
|
||||
)
|
||||
nodelist = parser.parse(("endfilter",))
|
||||
|
@ -484,5 +484,5 @@ def import_library(name):
|
||||
return module.register
|
||||
except AttributeError:
|
||||
raise InvalidTemplateLibrary(
|
||||
"Module %s does not have a variable named 'register'" % name,
|
||||
"Module %s does not have a variable named 'register'" % name,
|
||||
)
|
||||
|
@ -3,7 +3,7 @@ Parser and utilities for the smart 'if' tag
|
||||
"""
|
||||
|
||||
# Using a simple top down parser, as described here:
|
||||
# https://11l-lang.org/archive/simple-top-down-parsing/
|
||||
# https://11l-lang.org/archive/simple-top-down-parsing/
|
||||
# 'led' = left denotation
|
||||
# 'nud' = null denotation
|
||||
# 'bp' = binding power (left = lbp, right = rbp)
|
||||
@ -60,7 +60,7 @@ def infix(bp, func):
|
||||
try:
|
||||
return func(context, self.first, self.second)
|
||||
except Exception:
|
||||
# Templates shouldn't throw exceptions when rendering. We are
|
||||
# Templates shouldn't throw exceptions when rendering. We are
|
||||
# most likely to get exceptions for things like {% if foo in bar
|
||||
# %} where 'bar' does not support 'in', so default to False
|
||||
return False
|
||||
|
@ -77,7 +77,7 @@ def do_cache(parser, token):
|
||||
|
||||
Optionally the cache to use may be specified thus::
|
||||
|
||||
{% cache .... using="cachename" %}
|
||||
{% cache .... using="cachename" %}
|
||||
|
||||
Each unique set of arguments will result in a unique cache entry.
|
||||
"""
|
||||
|
@ -177,7 +177,7 @@ class ClientHandler(BaseHandler):
|
||||
request_started.connect(close_old_connections)
|
||||
request = WSGIRequest(environ)
|
||||
# sneaky little hack so that we can easily get round
|
||||
# CsrfViewMiddleware. This makes life easier, and is probably
|
||||
# CsrfViewMiddleware. This makes life easier, and is probably
|
||||
# required for backwards compatibility with external tests against
|
||||
# admin views.
|
||||
request._dont_enforce_csrf_checks = not self.enforce_csrf_checks
|
||||
|
@ -101,7 +101,7 @@ class Archive:
|
||||
|
||||
class BaseArchive:
|
||||
"""
|
||||
Base Archive class. Implementations should inherit this class.
|
||||
Base Archive class. Implementations should inherit this class.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
|
@ -35,7 +35,7 @@ def salted_hmac(key_salt, value, secret=None, *, algorithm="sha1"):
|
||||
raise InvalidAlgorithm(
|
||||
"%r is not an algorithm accepted by the hashlib module." % algorithm
|
||||
) from e
|
||||
# We need to generate a derived key from our base key. We can do this by
|
||||
# We need to generate a derived key from our base key. We can do this by
|
||||
# passing the key_salt and our base key through a pseudo-random function.
|
||||
key = hasher(key_salt + secret).digest()
|
||||
# If len(key_salt + secret) > block size of the hash algorithm, the above
|
||||
|
@ -39,7 +39,7 @@ def timesince(d, now=None, reversed=False, time_strings=None, depth=2):
|
||||
but also between 2007/08/10 and 2008/09/10 despite the delta being 393 days
|
||||
in the former case and 397 in the latter.
|
||||
|
||||
Up to `depth` adjacent units will be displayed. For example,
|
||||
Up to `depth` adjacent units will be displayed. For example,
|
||||
"2 weeks, 3 days" and "1 year, 3 months" are possible outputs, but
|
||||
"2 weeks, 3 hours" and "1 year, 5 days" are not.
|
||||
|
||||
|
@ -9,7 +9,7 @@ csrf_protect = decorator_from_middleware(CsrfViewMiddleware)
|
||||
csrf_protect.__name__ = "csrf_protect"
|
||||
csrf_protect.__doc__ = """
|
||||
This decorator adds CSRF protection in exactly the same way as
|
||||
CsrfViewMiddleware, but it can be used on a per view basis. Using both, or
|
||||
CsrfViewMiddleware, but it can be used on a per view basis. Using both, or
|
||||
using the decorator multiple times, is harmless and efficient.
|
||||
"""
|
||||
|
||||
|
@ -20,7 +20,7 @@ conditional_page = decorator_from_middleware(ConditionalGetMiddleware)
|
||||
|
||||
def require_http_methods(request_method_list):
|
||||
"""
|
||||
Decorator to make a view only accept particular request methods. Usage::
|
||||
Decorator to make a view only accept particular request methods. Usage::
|
||||
|
||||
@require_http_methods(["GET", "POST"])
|
||||
def my_view(request):
|
||||
|
@ -123,7 +123,7 @@ class ModelFormMixin(FormMixin, SingleObjectMixin):
|
||||
url = self.object.get_absolute_url()
|
||||
except AttributeError:
|
||||
raise ImproperlyConfigured(
|
||||
"No URL to redirect to. Either provide a url or define"
|
||||
"No URL to redirect to. Either provide a url or define"
|
||||
" a get_absolute_url method on the Model."
|
||||
)
|
||||
return url
|
||||
|
@ -37,7 +37,7 @@ def serve(request, path, document_root=None, show_indexes=False):
|
||||
|
||||
in your URLconf. You must provide the ``document_root`` param. You may
|
||||
also set ``show_indexes`` to ``True`` if you'd like to serve a basic index
|
||||
of the directory. This index view will use the template hardcoded below,
|
||||
of the directory. This index view will use the template hardcoded below,
|
||||
but if you'd like to override it, you can create a template called
|
||||
``static/directory_index.html``.
|
||||
"""
|
||||
@ -105,7 +105,7 @@ def was_modified_since(header=None, mtime=0):
|
||||
Was something modified since the user last downloaded it?
|
||||
|
||||
header
|
||||
This is the value of the If-Modified-Since header. If this is None,
|
||||
This is the value of the If-Modified-Since header. If this is None,
|
||||
I'll just return True.
|
||||
|
||||
mtime
|
||||
|
12
docs/conf.py
12
docs/conf.py
@ -198,23 +198,23 @@ suppress_warnings = ["app.add_directive", "epub.duplicated_toc_entry"]
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = "djangodocs"
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
html_theme_path = ["_theme"]
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
# html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
# html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
@ -222,7 +222,7 @@ html_theme_path = ["_theme"]
|
||||
# html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
# html_favicon = None
|
||||
|
||||
@ -264,7 +264,7 @@ html_additional_pages = {}
|
||||
# html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
# html_use_opensearch = ''
|
||||
|
||||
|
@ -54,7 +54,7 @@ totally fine with GeoDjango. Your mileage may vary.
|
||||
.. note::
|
||||
|
||||
The GeoDjango interfaces to GEOS, GDAL, and GeoIP may be used
|
||||
independently of Django. In other words, no database or settings file
|
||||
independently of Django. In other words, no database or settings file
|
||||
required -- import them as normal from :mod:`django.contrib.gis`.
|
||||
|
||||
.. _PROJ: https://proj.org/
|
||||
|
@ -50,7 +50,7 @@ spatial databases currently supported.
|
||||
open source spatial database.
|
||||
|
||||
The geospatial libraries required for a GeoDjango installation depends
|
||||
on the spatial database used. The following lists the library requirements,
|
||||
on the spatial database used. The following lists the library requirements,
|
||||
supported versions, and any notes for each of the supported database backends:
|
||||
|
||||
================== ============================== ================== =========================================
|
||||
@ -108,7 +108,7 @@ If you can't find the solution to your problem here then participate in the
|
||||
community! You can:
|
||||
|
||||
* Ask your question on the `GeoDjango`__ forum.
|
||||
* File a ticket on the `Django trac`__ if you think there's a bug. Make
|
||||
* File a ticket on the `Django trac`__ if you think there's a bug. Make
|
||||
sure to provide a complete description of the problem, versions used,
|
||||
and specify the component as "GIS".
|
||||
|
||||
@ -133,9 +133,9 @@ system.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
A user may set this environment variable to customize the library paths
|
||||
they want to use. The typical library directory for software
|
||||
built from source is ``/usr/local/lib``. Thus, ``/usr/local/lib`` needs
|
||||
to be included in the ``LD_LIBRARY_PATH`` variable. For example, the user
|
||||
they want to use. The typical library directory for software
|
||||
built from source is ``/usr/local/lib``. Thus, ``/usr/local/lib`` needs
|
||||
to be included in the ``LD_LIBRARY_PATH`` variable. For example, the user
|
||||
could place the following in their bash profile:
|
||||
|
||||
.. code-block:: shell
|
||||
@ -148,7 +148,7 @@ Setting system library path
|
||||
On GNU/Linux systems, there is typically a file in ``/etc/ld.so.conf``, which may include
|
||||
additional paths from files in another directory, such as ``/etc/ld.so.conf.d``.
|
||||
As the root user, add the custom library path (like ``/usr/local/lib``) on a
|
||||
new line in ``ld.so.conf``. This is *one* example of how to do so:
|
||||
new line in ``ld.so.conf``. This is *one* example of how to do so:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
@ -156,8 +156,8 @@ new line in ``ld.so.conf``. This is *one* example of how to do so:
|
||||
$ sudo ldconfig
|
||||
|
||||
For OpenSolaris users, the system library path may be modified using the
|
||||
``crle`` utility. Run ``crle`` with no options to see the current configuration
|
||||
and use ``crle -l`` to set with the new library path. Be *very* careful when
|
||||
``crle`` utility. Run ``crle`` with no options to see the current configuration
|
||||
and use ``crle -l`` to set with the new library path. Be *very* careful when
|
||||
modifying the system library path:
|
||||
|
||||
.. code-block:: shell
|
||||
@ -170,9 +170,9 @@ Install ``binutils``
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
GeoDjango uses the ``find_library`` function (from the ``ctypes.util`` Python
|
||||
module) to discover libraries. The ``find_library`` routine uses a program
|
||||
module) to discover libraries. The ``find_library`` routine uses a program
|
||||
called ``objdump`` (part of the ``binutils`` package) to verify a shared
|
||||
library on GNU/Linux systems. Thus, if ``binutils`` is not installed on your
|
||||
library on GNU/Linux systems. Thus, if ``binutils`` is not installed on your
|
||||
Linux system then Python's ctypes may not be able to find your library even if
|
||||
your library path is set correctly and geospatial libraries were built perfectly.
|
||||
|
||||
@ -216,7 +216,7 @@ Python
|
||||
~~~~~~
|
||||
|
||||
Although macOS comes with Python installed, users can use `framework
|
||||
installers`__ provided by the Python Software Foundation. An advantage to
|
||||
installers`__ provided by the Python Software Foundation. An advantage to
|
||||
using the installer is that macOS's Python will remain "pristine" for internal
|
||||
operating system use.
|
||||
|
||||
@ -293,7 +293,7 @@ MacPorts
|
||||
~~~~~~~~
|
||||
|
||||
`MacPorts`__ may be used to install GeoDjango prerequisites on computers
|
||||
running macOS. Because MacPorts still builds the software from source,
|
||||
running macOS. Because MacPorts still builds the software from source,
|
||||
`Xcode`_ is required.
|
||||
|
||||
Summary:
|
||||
@ -344,7 +344,7 @@ PostgreSQL
|
||||
~~~~~~~~~~
|
||||
|
||||
Download the latest `PostgreSQL 15.x installer`__ from the
|
||||
`EnterpriseDB`__ website. After downloading, run the installer, follow the
|
||||
`EnterpriseDB`__ website. After downloading, run the installer, follow the
|
||||
on-screen directions, and keep the default options unless you know the
|
||||
consequences of changing them.
|
||||
|
||||
@ -392,7 +392,7 @@ OSGeo4W
|
||||
|
||||
The `OSGeo4W installer`_ helps to install the PROJ, GDAL, and GEOS libraries
|
||||
required by GeoDjango. First, download the `OSGeo4W installer`_, and
|
||||
run it. Select :menuselection:`Express Web-GIS Install` and click next. In the
|
||||
run it. Select :menuselection:`Express Web-GIS Install` and click next. In the
|
||||
'Select Packages' list, ensure that GDAL is selected. If any other packages are
|
||||
enabled by default, they are not required by GeoDjango and may be unchecked
|
||||
safely. After clicking next and accepting the license agreements, the packages
|
||||
@ -406,7 +406,7 @@ Modify Windows environment
|
||||
|
||||
In order to use GeoDjango, you will need to add your OSGeo4W
|
||||
directories to your Windows system ``Path``, as well as create ``GDAL_DATA``
|
||||
and ``PROJ_LIB`` environment variables. The following set of commands,
|
||||
and ``PROJ_LIB`` environment variables. The following set of commands,
|
||||
executable with ``cmd.exe``, will set this up. Restart your device
|
||||
once this is complete for new environment variables to be recognized:
|
||||
|
||||
|
@ -95,7 +95,7 @@ overridden:
|
||||
:ref:`ModelForm documentation
|
||||
<overriding-modelform-clean-method>` for more information)
|
||||
|
||||
These methods are run in the order given above, one field at a time. That is,
|
||||
These methods are run in the order given above, one field at a time. That is,
|
||||
for each field in the form (in the order they are declared in the form
|
||||
definition), the ``Field.clean()`` method (or its override) is run, then
|
||||
``clean_<fieldname>()``. Finally, once those two methods are run for every
|
||||
|
@ -225,7 +225,7 @@ foundation for custom widgets.
|
||||
.. class:: Widget(attrs=None)
|
||||
|
||||
This abstract class cannot be rendered, but provides the basic attribute
|
||||
:attr:`~Widget.attrs`. You may also implement or override the
|
||||
:attr:`~Widget.attrs`. You may also implement or override the
|
||||
:meth:`~Widget.render()` method on custom widgets.
|
||||
|
||||
.. attribute:: Widget.attrs
|
||||
|
@ -830,7 +830,7 @@ an expression that's compatible in a window clause.
|
||||
|
||||
The ``partition_by`` argument accepts an expression or a sequence of
|
||||
expressions (column names should be wrapped in an ``F``-object) that control
|
||||
the partitioning of the rows. Partitioning narrows which rows are used to
|
||||
the partitioning of the rows. Partitioning narrows which rows are used to
|
||||
compute the result set.
|
||||
|
||||
The :ref:`output_field<output-field>` is specified either as an argument or by
|
||||
|
@ -31,7 +31,7 @@ need to :meth:`~Model.save()`.
|
||||
method. If you do so, however, take care not to change the calling
|
||||
signature as any change may prevent the model instance from being saved.
|
||||
Additionally, referring to model fields within ``__init__`` may potentially
|
||||
result in infinite recursion errors in some circumstances. Rather than
|
||||
result in infinite recursion errors in some circumstances. Rather than
|
||||
overriding ``__init__``, try using one of these approaches:
|
||||
|
||||
#. Add a classmethod on the model class::
|
||||
|
@ -149,7 +149,7 @@ following methods:
|
||||
This class follows the :ref:`Query Expression API <query-expression>`, which
|
||||
implies that you can use ``<expression>__<transform1>__<transform2>``. It's
|
||||
a specialized :ref:`Func() expression <func-expressions>` that only accepts
|
||||
one argument. It can also be used on the right hand side of a filter or
|
||||
one argument. It can also be used on the right hand side of a filter or
|
||||
directly as an annotation.
|
||||
|
||||
.. attribute:: bilateral
|
||||
|
@ -181,7 +181,7 @@ not be looking at your Django code. For example::
|
||||
includes
|
||||
|
||||
#. Adding an automatic primary key field to the model if you don't
|
||||
declare it. To avoid confusion for later code readers, it's
|
||||
declare it. To avoid confusion for later code readers, it's
|
||||
recommended to specify all the columns from the database table you
|
||||
are modeling when using unmanaged models.
|
||||
|
||||
|
@ -32,7 +32,7 @@ class ActionAdmin(admin.ModelAdmin):
|
||||
|
||||
def get_urls(self):
|
||||
# Add the URL of our custom 'add_view' view to the front of the URLs
|
||||
# list. Remove the existing one(s) first
|
||||
# list. Remove the existing one(s) first
|
||||
from django.urls import re_path
|
||||
|
||||
def wrap(view):
|
||||
|
@ -133,7 +133,7 @@ class AuthContextProcessorTests(TestCase):
|
||||
"""
|
||||
The lazy objects returned behave just like the wrapped objects.
|
||||
"""
|
||||
# These are 'functional' level tests for common use cases. Direct
|
||||
# These are 'functional' level tests for common use cases. Direct
|
||||
# testing of the implementation (SimpleLazyObject) is in the 'utils'
|
||||
# tests.
|
||||
self.client.login(username="super", password="secret")
|
||||
@ -148,7 +148,7 @@ class AuthContextProcessorTests(TestCase):
|
||||
# A Q() comparing a user and with another Q() (in an AND or OR fashion).
|
||||
Q(user=response.context["user"]) & Q(someflag=True)
|
||||
|
||||
# Tests for user equality. This is hard because User defines
|
||||
# Tests for user equality. This is hard because User defines
|
||||
# equality in a non-duck-typing way
|
||||
# See bug #12060
|
||||
self.assertEqual(response.context["user"], user)
|
||||
|
@ -153,7 +153,7 @@ class PasswordResetTest(AuthViewsTestCase):
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
self.assertIn("http://", mail.outbox[0].body)
|
||||
self.assertEqual(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email)
|
||||
# optional multipart text/html email has been added. Make sure original,
|
||||
# optional multipart text/html email has been added. Make sure original,
|
||||
# default functionality is 100% the same
|
||||
self.assertFalse(mail.outbox[0].message().is_multipart())
|
||||
|
||||
|
@ -338,12 +338,12 @@ class CsrfViewMiddlewareTestMixin(CsrfFunctionTestMixin):
|
||||
If get_token() is not called, the view middleware does not
|
||||
add a cookie.
|
||||
"""
|
||||
# This is important to make pages cacheable. Pages which do call
|
||||
# This is important to make pages cacheable. Pages which do call
|
||||
# get_token(), assuming they use the token, are not cacheable because
|
||||
# the token is specific to the user
|
||||
req = self._get_request()
|
||||
# non_token_view_using_request_processor does not call get_token(), but
|
||||
# does use the csrf request processor. By using this, we are testing
|
||||
# does use the csrf request processor. By using this, we are testing
|
||||
# that the view processor is properly lazy and doesn't call get_token()
|
||||
# until needed.
|
||||
mw = CsrfViewMiddleware(non_token_view_using_request_processor)
|
||||
|
@ -740,7 +740,7 @@ class FileUploadTests(TestCase):
|
||||
|
||||
# Maybe this is a little more complicated that it needs to be; but if
|
||||
# the django.test.client.FakePayload.read() implementation changes then
|
||||
# this test would fail. So we need to know exactly what kind of error
|
||||
# this test would fail. So we need to know exactly what kind of error
|
||||
# it raises when there is an attempt to read more than the available bytes:
|
||||
try:
|
||||
client.FakePayload(b"a").read(2)
|
||||
|
@ -722,7 +722,7 @@ class NaturalKeyFixtureTests(TestCase):
|
||||
|
||||
def test_dependency_sorting(self):
|
||||
"""
|
||||
It doesn't matter what order you mention the models, Store *must* be
|
||||
It doesn't matter what order you mention the models, Store *must* be
|
||||
serialized before then Person, and both must be serialized before Book.
|
||||
"""
|
||||
sorted_deps = serializers.sort_dependencies(
|
||||
@ -897,7 +897,7 @@ class M2MNaturalKeyFixtureTests(TestCase):
|
||||
def test_dependency_sorting_m2m_complex(self):
|
||||
"""
|
||||
M2M relations with explicit through models should NOT count as
|
||||
dependencies. The through model itself will have dependencies, though.
|
||||
dependencies. The through model itself will have dependencies, though.
|
||||
"""
|
||||
sorted_deps = serializers.sort_dependencies(
|
||||
[("fixtures_regress", [M2MComplexA, M2MComplexB, M2MThroughAB])]
|
||||
|
@ -48,7 +48,7 @@ class GenericRelationTests(TestCase):
|
||||
def test_reverse_relation_pk(self):
|
||||
"""
|
||||
The correct column name is used for the primary key on the
|
||||
originating model of a query. See #12664.
|
||||
originating model of a query. See #12664.
|
||||
"""
|
||||
p = Person.objects.create(account=23, name="Chef")
|
||||
Address.objects.create(
|
||||
|
@ -177,7 +177,7 @@ class CreateViewTests(TestCase):
|
||||
|
||||
def test_create_without_redirect(self):
|
||||
msg = (
|
||||
"No URL to redirect to. Either provide a url or define a "
|
||||
"No URL to redirect to. Either provide a url or define a "
|
||||
"get_absolute_url method on the Model."
|
||||
)
|
||||
with self.assertRaisesMessage(ImproperlyConfigured, msg):
|
||||
@ -339,7 +339,7 @@ class UpdateViewTests(TestCase):
|
||||
|
||||
def test_update_without_redirect(self):
|
||||
msg = (
|
||||
"No URL to redirect to. Either provide a url or define a "
|
||||
"No URL to redirect to. Either provide a url or define a "
|
||||
"get_absolute_url method on the Model."
|
||||
)
|
||||
with self.assertRaisesMessage(ImproperlyConfigured, msg):
|
||||
|
@ -158,7 +158,7 @@ class DistanceTest(TestCase):
|
||||
"""
|
||||
Test distance lookups on geodetic coordinate systems.
|
||||
"""
|
||||
# Line is from Canberra to Sydney. Query is for all other cities within
|
||||
# Line is from Canberra to Sydney. Query is for all other cities within
|
||||
# a 100km of that line (which should exclude only Hobart & Adelaide).
|
||||
line = GEOSGeometry("LINESTRING(144.9630 -37.8143,151.2607 -33.8870)", 4326)
|
||||
dist_qs = AustraliaCity.objects.filter(point__distance_lte=(line, D(km=100)))
|
||||
@ -670,7 +670,7 @@ class DistanceFunctionsTests(FuncTestMixin, TestCase):
|
||||
# Having our buffer in the SRID of the transformation and of the field
|
||||
# -- should get the same results. The first buffer has no need for
|
||||
# transformation SQL because it is the same SRID as what was given
|
||||
# to `transform()`. The second buffer will need to be transformed,
|
||||
# to `transform()`. The second buffer will need to be transformed,
|
||||
# however.
|
||||
buf1 = z.poly.centroid.buffer(100)
|
||||
buf2 = buf1.transform(4269, clone=True)
|
||||
|
@ -235,7 +235,7 @@ class DataSourceTest(SimpleTestCase):
|
||||
# See ticket #9448.
|
||||
def get_layer():
|
||||
# This DataSource object is not accessible outside this
|
||||
# scope. However, a reference should still be kept alive
|
||||
# scope. However, a reference should still be kept alive
|
||||
# on the `Layer` returned.
|
||||
ds = DataSource(source.ds)
|
||||
return ds[0]
|
||||
@ -332,7 +332,7 @@ class DataSourceTest(SimpleTestCase):
|
||||
self.assertEqual(1, len(feats))
|
||||
self.assertEqual("Houston", feats[0].get("Name"))
|
||||
|
||||
# Clearing the spatial filter by setting it to None. Now
|
||||
# Clearing the spatial filter by setting it to None. Now
|
||||
# should indicate that there are 3 features in the Layer.
|
||||
lyr.spatial_filter = None
|
||||
self.assertEqual(3, len(lyr))
|
||||
|
@ -48,7 +48,7 @@ city_data = (
|
||||
city_dict = {name: coords for name, coords in city_data}
|
||||
|
||||
# 3D freeway data derived from the National Elevation Dataset:
|
||||
# http://seamless.usgs.gov/products/9arc.php
|
||||
# http://seamless.usgs.gov/products/9arc.php
|
||||
interstate_data = (
|
||||
(
|
||||
"I-45",
|
||||
@ -137,7 +137,7 @@ class Geo3DTest(Geo3DLoadingHelper, TestCase):
|
||||
"""
|
||||
Only a subset of the PostGIS routines are 3D-enabled, and this TestCase
|
||||
tries to test the features that can handle 3D and that are also
|
||||
available within GeoDjango. For more information, see the PostGIS docs
|
||||
available within GeoDjango. For more information, see the PostGIS docs
|
||||
on the routines that support 3D:
|
||||
|
||||
https://postgis.net/docs/PostGIS_Special_Functions_Index.html#PostGIS_3D_Functions
|
||||
|
@ -20,7 +20,7 @@ class TestGeoRSS1(feeds.Feed):
|
||||
class TestGeoRSS2(TestGeoRSS1):
|
||||
def geometry(self, obj):
|
||||
# This should attach a <georss:box> element for the extent of
|
||||
# of the cities in the database. This tuple came from
|
||||
# the cities in the database. This tuple came from
|
||||
# calling `City.objects.aggregate(Extent())` -- we can't do that call
|
||||
# here because `Extent` is not implemented for MySQL/Oracle.
|
||||
return (-123.30, -41.32, 174.78, 48.46)
|
||||
|
@ -133,7 +133,7 @@ class GeoModelTest(TestCase):
|
||||
tx = Country.objects.get(mpoly__intersects=other_srid_pnt)
|
||||
self.assertEqual("Texas", tx.name)
|
||||
|
||||
# Creating San Antonio. Remember the Alamo.
|
||||
# Creating San Antonio. Remember the Alamo.
|
||||
sa = City.objects.create(name="San Antonio", point=other_srid_pnt)
|
||||
|
||||
# Now verifying that San Antonio was transformed correctly
|
||||
|
@ -208,7 +208,7 @@ class LayerMapTest(TestCase):
|
||||
)
|
||||
|
||||
# If a mapping is specified as a collection, all OGR fields that
|
||||
# are not collections will be converted into them. For example,
|
||||
# are not collections will be converted into them. For example,
|
||||
# a Point column would be converted to MultiPoint. Other things being done
|
||||
# w/the keyword args:
|
||||
# `transform=False`: Specifies that no transform is to be done; this
|
||||
@ -217,7 +217,7 @@ class LayerMapTest(TestCase):
|
||||
#
|
||||
# `unique='name'`: Creates models on the condition that they have
|
||||
# unique county names; geometries from each feature however will be
|
||||
# appended to the geometry collection of the unique model. Thus,
|
||||
# appended to the geometry collection of the unique model. Thus,
|
||||
# all of the various islands in Honolulu county will be in one
|
||||
# database record with a MULTIPOLYGON type.
|
||||
lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique="name")
|
||||
@ -270,7 +270,7 @@ class LayerMapTest(TestCase):
|
||||
lm.save(fid_range=slice(None, 1), silent=True, strict=True) # layer[:1]
|
||||
|
||||
# Only Pueblo & Honolulu counties should be present because of
|
||||
# the `unique` keyword. Have to set `order_by` on this QuerySet
|
||||
# the `unique` keyword. Have to set `order_by` on this QuerySet
|
||||
# or else MySQL will return a different ordering than the other dbs.
|
||||
qs = County.objects.order_by("name")
|
||||
self.assertEqual(2, qs.count())
|
||||
@ -290,7 +290,7 @@ class LayerMapTest(TestCase):
|
||||
self.county_helper(county_feat=False)
|
||||
|
||||
def test_model_inheritance(self):
|
||||
"Tests LayerMapping on inherited models. See #12093."
|
||||
"Tests LayerMapping on inherited models. See #12093."
|
||||
icity_mapping = {
|
||||
"name": "Name",
|
||||
"population": "Population",
|
||||
@ -310,7 +310,7 @@ class LayerMapTest(TestCase):
|
||||
self.assertEqual(3, ICity2.objects.count())
|
||||
|
||||
def test_invalid_layer(self):
|
||||
"Tests LayerMapping on invalid geometries. See #15378."
|
||||
"Tests LayerMapping on invalid geometries. See #15378."
|
||||
invalid_mapping = {"point": "POINT"}
|
||||
lm = LayerMapping(Invalid, invalid_shp, invalid_mapping, source_srs=4326)
|
||||
lm.save(silent=True)
|
||||
|
@ -77,7 +77,7 @@ class RelatedGeoModelTest(TestCase):
|
||||
aggs = City.objects.aggregate(Union("location__point"))
|
||||
|
||||
# These are the points that are components of the aggregate geographic
|
||||
# union that is returned. Each point # corresponds to City PK.
|
||||
# union that is returned. Each point # corresponds to City PK.
|
||||
p1 = Point(-104.528056, 33.387222)
|
||||
p2 = Point(-97.516111, 33.058333)
|
||||
p3 = Point(-79.460734, 40.18476)
|
||||
@ -133,7 +133,7 @@ class RelatedGeoModelTest(TestCase):
|
||||
)
|
||||
|
||||
# Now creating a second Parcel where the borders are the same, just
|
||||
# in different coordinate systems. The center points are also the
|
||||
# in different coordinate systems. The center points are also the
|
||||
# same (but in different coordinate systems), and this time they
|
||||
# actually correspond to the centroid of the border.
|
||||
c1 = b1.centroid
|
||||
@ -210,7 +210,7 @@ class RelatedGeoModelTest(TestCase):
|
||||
def test09_pk_relations(self):
|
||||
"Ensuring correct primary key column is selected across relations. See #10757."
|
||||
# The expected ID values -- notice the last two location IDs
|
||||
# are out of order. Dallas and Houston have location IDs that differ
|
||||
# are out of order. Dallas and Houston have location IDs that differ
|
||||
# from their PKs -- this is done to ensure that the related location
|
||||
# ID column is selected instead of ID column for the city.
|
||||
city_ids = (1, 2, 3, 4, 5)
|
||||
@ -262,7 +262,7 @@ class RelatedGeoModelTest(TestCase):
|
||||
|
||||
@skipUnlessDBFeature("allows_group_by_lob")
|
||||
def test13c_count(self):
|
||||
"Testing `Count` aggregate with `.values()`. See #15305."
|
||||
"Testing `Count` aggregate with `.values()`. See #15305."
|
||||
qs = (
|
||||
Location.objects.filter(id=5)
|
||||
.annotate(num_cities=Count("city"))
|
||||
@ -427,12 +427,12 @@ class RelatedGeoModelTest(TestCase):
|
||||
"""
|
||||
qs = Article.objects.select_related("author__article")
|
||||
# This triggers TypeError when `get_default_columns` has no `local_only`
|
||||
# keyword. The TypeError is swallowed if QuerySet is actually
|
||||
# keyword. The TypeError is swallowed if QuerySet is actually
|
||||
# evaluated as list generation swallows TypeError in CPython.
|
||||
str(qs.query)
|
||||
|
||||
def test16_annotated_date_queryset(self):
|
||||
"Ensure annotated date querysets work if spatial backend is used. See #14648."
|
||||
"Ensure annotated date querysets work if spatial backend is used. See #14648."
|
||||
birth_years = [
|
||||
dt.year
|
||||
for dt in list(
|
||||
|
@ -55,7 +55,7 @@ class OneTimeReceiver:
|
||||
|
||||
|
||||
# We connect receiver here and not in unit test code because we need to
|
||||
# connect receiver before test runner creates database. That is, sequence of
|
||||
# connect receiver before test runner creates database. That is, sequence of
|
||||
# actions would be:
|
||||
#
|
||||
# 1. Test runner imports this module.
|
||||
|
@ -445,7 +445,7 @@ class MigrateTests(MigrationTestBase):
|
||||
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"})
|
||||
def test_showmigrations_list(self):
|
||||
"""
|
||||
showmigrations --list displays migrations and whether or not they're
|
||||
showmigrations --list displays migrations and whether or not they're
|
||||
applied.
|
||||
"""
|
||||
out = io.StringIO()
|
||||
|
@ -71,7 +71,7 @@ class ImageFieldTestMixin(SerializeMixin):
|
||||
(if defined) the image field is caching to.
|
||||
|
||||
Note, this method will check for dimension fields named by adding
|
||||
"_width" or "_height" to the name of the ImageField. So, the
|
||||
"_width" or "_height" to the name of the ImageField. So, the
|
||||
models used in these tests must have their fields named
|
||||
accordingly.
|
||||
|
||||
@ -294,7 +294,7 @@ class ImageFieldTwoDimensionsTests(ImageFieldTestMixin, TestCase):
|
||||
# Test dimensions after fetching from database.
|
||||
p = self.PersonModel.objects.get(name="Joe")
|
||||
# Bug 11084: Dimensions should not get recalculated if file is
|
||||
# coming from the database. We test this by checking if the file
|
||||
# coming from the database. We test this by checking if the file
|
||||
# was opened.
|
||||
self.assertIs(p.mugshot.was_opened, False)
|
||||
self.check_dimensions(p, 4, 8)
|
||||
@ -442,7 +442,7 @@ class TwoImageFieldTests(ImageFieldTestMixin, TestCase):
|
||||
# Test dimensions after fetching from database.
|
||||
p = self.PersonModel.objects.get(name="Joe")
|
||||
# Bug 11084: Dimensions should not get recalculated if file is
|
||||
# coming from the database. We test this by checking if the file
|
||||
# coming from the database. We test this by checking if the file
|
||||
# was opened.
|
||||
self.assertIs(p.mugshot.was_opened, False)
|
||||
self.assertIs(p.headshot.was_opened, False)
|
||||
|
@ -600,7 +600,7 @@ class ModelFormBaseTest(TestCase):
|
||||
def test_mixmodel_form(self):
|
||||
class MixModelForm(BaseCategoryForm):
|
||||
"""Don't allow more than one 'model' definition in the
|
||||
inheritance hierarchy. Technically, it would generate a valid
|
||||
inheritance hierarchy. Technically, it would generate a valid
|
||||
form, but the fact that the resulting save method won't deal with
|
||||
multiple objects is likely to trip up people not familiar with the
|
||||
mechanics.
|
||||
|
@ -763,7 +763,7 @@ class ModelFormsetTest(TestCase):
|
||||
|
||||
def test_inline_formsets_save_as_new(self):
|
||||
# The save_as_new parameter lets you re-associate the data to a new
|
||||
# instance. This is used in the admin for save_as functionality.
|
||||
# instance. This is used in the admin for save_as functionality.
|
||||
AuthorBooksFormSet = inlineformset_factory(
|
||||
Author, Book, can_delete=False, extra=2, fields="__all__"
|
||||
)
|
||||
|
@ -731,9 +731,9 @@ class ModelAdminTests(TestCase):
|
||||
)
|
||||
|
||||
def test_foreign_key_as_radio_field(self):
|
||||
# Now specify all the fields as radio_fields. Widgets should now be
|
||||
# Now specify all the fields as radio_fields. Widgets should now be
|
||||
# RadioSelect, and the choices list should have a first entry of 'None' if
|
||||
# blank=True for the model field. Finally, the widget should have the
|
||||
# blank=True for the model field. Finally, the widget should have the
|
||||
# 'radiolist' attr, and 'inline' as well if the field is specified HORIZONTAL.
|
||||
class ConcertAdmin(ModelAdmin):
|
||||
radio_fields = {
|
||||
|
@ -55,7 +55,7 @@ class PaginationTests(SimpleTestCase):
|
||||
self.assertEqual(
|
||||
expected,
|
||||
got,
|
||||
"For '%s', expected %s but got %s. Paginator parameters were: %s"
|
||||
"For '%s', expected %s but got %s. Paginator parameters were: %s"
|
||||
% (name, expected, got, params),
|
||||
)
|
||||
|
||||
@ -65,7 +65,7 @@ class PaginationTests(SimpleTestCase):
|
||||
self.assertEqual(
|
||||
expected,
|
||||
await got(),
|
||||
"For '%s', expected %s but got %s. Paginator parameters were: %s"
|
||||
"For '%s', expected %s but got %s. Paginator parameters were: %s"
|
||||
% (name, expected, got, params),
|
||||
)
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user