Fixed #23866 -- Harmonized refs to Django documentation from code
This commit is contained in:
parent
a6f0b6a98f
commit
234a2e0b6b
|
@ -2,13 +2,14 @@ from django.core.exceptions import ImproperlyConfigured
|
|||
|
||||
# Want to get everything from the 'normal' models package.
|
||||
from django.db.models import * # NOQA
|
||||
from django.utils.version import get_docs_version
|
||||
|
||||
from django.contrib.gis.geos import HAS_GEOS
|
||||
|
||||
if not HAS_GEOS:
|
||||
raise ImproperlyConfigured(
|
||||
"GEOS is required and has not been detected. Are you sure it is installed? "
|
||||
"See also https://docs.djangoproject.com/en/stable/ref/contrib/gis/install/geolibs/")
|
||||
"See also https://docs.djangoproject.com/en/%s/ref/contrib/gis/install/geolibs/" % get_docs_version())
|
||||
|
||||
# Geographic aggregate functions
|
||||
from django.contrib.gis.db.models.aggregates import * # NOQA
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from django.core.management.base import BaseCommand, CommandError
|
||||
from django.utils import six
|
||||
from django.conf import settings
|
||||
from django.db import connections, DEFAULT_DB_ALIAS, migrations
|
||||
from django.db.migrations.loader import AmbiguityError
|
||||
|
@ -7,6 +6,8 @@ from django.db.migrations.executor import MigrationExecutor
|
|||
from django.db.migrations.writer import MigrationWriter
|
||||
from django.db.migrations.optimizer import MigrationOptimizer
|
||||
from django.db.migrations.migration import SwappableTuple
|
||||
from django.utils import six
|
||||
from django.utils.version import get_docs_version
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
@ -85,7 +86,7 @@ class Command(BaseCommand):
|
|||
raise CommandError(
|
||||
"You cannot squash squashed migrations! Please transition "
|
||||
"it to a normal migration first: "
|
||||
"https://docs.djangoproject.com/en/1.7/topics/migrations/#squashing-migrations"
|
||||
"https://docs.djangoproject.com/en/%s/topics/migrations/#squashing-migrations" % get_docs_version()
|
||||
)
|
||||
operations.extend(smigration.operations)
|
||||
for dependency in smigration.dependencies:
|
||||
|
|
|
@ -10,6 +10,7 @@ from django.conf import settings
|
|||
from django.core.management.base import CommandError
|
||||
from django.db import models, router
|
||||
from django.utils.deprecation import RemovedInDjango19Warning
|
||||
from django.utils.version import get_docs_version
|
||||
|
||||
|
||||
def check_for_migrations(app_config, connection):
|
||||
|
@ -31,9 +32,11 @@ def sql_create(app_config, style, connection):
|
|||
if connection.settings_dict['ENGINE'] == 'django.db.backends.dummy':
|
||||
# This must be the "dummy" database backend, which means the user
|
||||
# hasn't set ENGINE for the database.
|
||||
raise CommandError("Django doesn't know which syntax to use for your SQL statements,\n" +
|
||||
"because you haven't properly specified the ENGINE setting for the database.\n" +
|
||||
"see: https://docs.djangoproject.com/en/dev/ref/settings/#databases")
|
||||
raise CommandError(
|
||||
"Django doesn't know which syntax to use for your SQL statements,\n"
|
||||
"because you haven't properly specified the ENGINE setting for the database.\n"
|
||||
"see: https://docs.djangoproject.com/en/%s/ref/settings/#databases" % get_docs_version()
|
||||
)
|
||||
|
||||
# Get installed models, so we generate REFERENCES right.
|
||||
# We trim models from the current app so that the sqlreset command does not
|
||||
|
|
|
@ -16,6 +16,7 @@ from django.template import Template, Context
|
|||
from django.utils import archive
|
||||
from django.utils.six.moves.urllib.request import urlretrieve
|
||||
from django.utils._os import rmtree_errorhandler
|
||||
from django.utils.version import get_docs_version
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from django.core.management.utils import handle_extensions
|
||||
|
||||
|
@ -100,15 +101,11 @@ class TemplateCommand(BaseCommand):
|
|||
base_name = '%s_name' % app_or_project
|
||||
base_subdir = '%s_template' % app_or_project
|
||||
base_directory = '%s_directory' % app_or_project
|
||||
if django.VERSION[-2] != 'final':
|
||||
docs_version = 'dev'
|
||||
else:
|
||||
docs_version = '%d.%d' % django.VERSION[:2]
|
||||
|
||||
context = Context(dict(options, **{
|
||||
base_name: name,
|
||||
base_directory: top_dir,
|
||||
'docs_version': docs_version,
|
||||
'docs_version': get_docs_version(),
|
||||
'django_version': django.__version__,
|
||||
}), autoescape=False)
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ from django.conf import settings
|
|||
from django.utils import six
|
||||
from django.utils.encoding import force_text, smart_text
|
||||
from django.utils.module_loading import import_string
|
||||
from django.utils.version import get_docs_version
|
||||
|
||||
|
||||
class InvalidBasesError(ValueError):
|
||||
|
@ -71,8 +72,8 @@ class ProjectState(object):
|
|||
raise InvalidBasesError(
|
||||
"Cannot resolve bases for %r\nThis can happen if you are inheriting models from an "
|
||||
"app with migrations (e.g. contrib.auth)\n in an app with no migrations; see "
|
||||
"https://docs.djangoproject.com/en/1.7/topics/migrations/#dependencies "
|
||||
"for more" % new_unrendered_models
|
||||
"https://docs.djangoproject.com/en/%s/topics/migrations/#dependencies "
|
||||
"for more" % (new_unrendered_models, get_docs_version())
|
||||
)
|
||||
unrendered_models = new_unrendered_models
|
||||
# make sure apps has no dangling references
|
||||
|
|
|
@ -18,6 +18,7 @@ from django.utils import datetime_safe, six
|
|||
from django.utils.encoding import force_text
|
||||
from django.utils.functional import Promise
|
||||
from django.utils.timezone import utc
|
||||
from django.utils.version import get_docs_version
|
||||
|
||||
|
||||
COMPILED_REGEX_TYPE = type(re.compile(''))
|
||||
|
@ -389,8 +390,8 @@ class MigrationWriter(object):
|
|||
"declared and used in the same class body). Please move "
|
||||
"the function into the main module body to use migrations.\n"
|
||||
"For more information, see "
|
||||
"https://docs.djangoproject.com/en/dev/topics/migrations/#serializing-values"
|
||||
% (value.__name__, module_name))
|
||||
"https://docs.djangoproject.com/en/%s/topics/migrations/#serializing-values"
|
||||
% (value.__name__, module_name, get_docs_version()))
|
||||
return "%s.%s" % (module_name, value.__name__), {"import %s" % module_name}
|
||||
# Other iterables
|
||||
elif isinstance(value, collections.Iterable):
|
||||
|
@ -419,8 +420,8 @@ class MigrationWriter(object):
|
|||
else:
|
||||
raise ValueError(
|
||||
"Cannot serialize: %r\nThere are some values Django cannot serialize into "
|
||||
"migration files.\nFor more, see https://docs.djangoproject.com/en/dev/"
|
||||
"topics/migrations/#migration-serializing" % value
|
||||
"migration files.\nFor more, see https://docs.djangoproject.com/en/%s/"
|
||||
"topics/migrations/#migration-serializing" % (value, get_docs_version())
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from __future__ import absolute_import # Avoid importing `importlib` from this package.
|
||||
from importlib import import_module
|
||||
|
||||
from django.utils.version import get_docs_version
|
||||
|
||||
|
||||
def deconstructible(*args, **kwargs):
|
||||
"""
|
||||
|
@ -38,8 +40,8 @@ def deconstructible(*args, **kwargs):
|
|||
"classes. Please move the object into the main module "
|
||||
"body to use migrations.\n"
|
||||
"For more information, see "
|
||||
"https://docs.djangoproject.com/en/dev/topics/migrations/#serializing-values"
|
||||
% (name, module_name))
|
||||
"https://docs.djangoproject.com/en/%s/topics/migrations/#serializing-values"
|
||||
% (name, module_name, get_docs_version()))
|
||||
return (
|
||||
path or '%s.%s' % (obj.__class__.__module__, name),
|
||||
obj._constructor_args[0],
|
||||
|
|
|
@ -52,6 +52,14 @@ def get_complete_version(version=None):
|
|||
return version
|
||||
|
||||
|
||||
def get_docs_version(version=None):
|
||||
version = get_complete_version(version)
|
||||
if version[3] != 'final':
|
||||
return 'dev'
|
||||
else:
|
||||
return '%d.%d' % version[:2]
|
||||
|
||||
|
||||
@lru_cache()
|
||||
def get_git_changeset():
|
||||
"""Returns a numeric identifier of the latest git changeset.
|
||||
|
|
|
@ -2,6 +2,7 @@ from django.conf import settings
|
|||
from django.http import HttpResponseForbidden
|
||||
from django.template import Context, Template
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.version import get_docs_version
|
||||
|
||||
# We include the template inline since we need to be able to reliably display
|
||||
# this error message, especially for the sake of developers, and there isn't any
|
||||
|
@ -58,7 +59,7 @@ CSRF_FAILURE_TEMPLATE = """
|
|||
|
||||
<p>In general, this can occur when there is a genuine Cross Site Request Forgery, or when
|
||||
<a
|
||||
href='http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ref-contrib-csrf'>Django's
|
||||
href='https://docs.djangoproject.com/en/{{ docs_version }}/ref/contrib/csrf/#ref-contrib-csrf'>Django's
|
||||
CSRF mechanism</a> has not been used correctly. For POST forms, you need to
|
||||
ensure:</p>
|
||||
|
||||
|
@ -66,7 +67,7 @@ CSRF_FAILURE_TEMPLATE = """
|
|||
<li>Your browser is accepting cookies.</li>
|
||||
|
||||
<li>The view function uses <a
|
||||
href='http://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-context-requestcontext'><code>RequestContext</code></a>
|
||||
href='https://docs.djangoproject.com/en/{{ docs_version }}/ref/templates/api/#subclassing-context-requestcontext'><code>RequestContext</code></a>
|
||||
for the template, instead of <code>Context</code>.</li>
|
||||
|
||||
<li>In the template, there is a <code>{% templatetag openblock %} csrf_token
|
||||
|
@ -126,6 +127,7 @@ def csrf_failure(request, reason=""):
|
|||
"re-enable them, at least for this site, or for 'same-origin' "
|
||||
"requests."),
|
||||
'DEBUG': settings.DEBUG,
|
||||
'docs_version': get_docs_version(),
|
||||
'more': _("More information is available with DEBUG=True."),
|
||||
})
|
||||
return HttpResponseForbidden(t.render(c), content_type='text/html')
|
||||
|
|
Loading…
Reference in New Issue