parent
d4fd31684a
commit
a8c15481f4
|
@ -18,7 +18,7 @@ class Apps:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, installed_apps=()):
|
def __init__(self, installed_apps=()):
|
||||||
# installed_apps is set to None when creating the master registry
|
# installed_apps is set to None when creating the main registry
|
||||||
# because it cannot be populated at that point. Other registries must
|
# because it cannot be populated at that point. Other registries must
|
||||||
# provide a list of installed apps and are populated immediately.
|
# provide a list of installed apps and are populated immediately.
|
||||||
if installed_apps is None and hasattr(sys.modules[__name__], "apps"):
|
if installed_apps is None and hasattr(sys.modules[__name__], "apps"):
|
||||||
|
@ -54,7 +54,7 @@ class Apps:
|
||||||
# `lazy_model_operation()` and `do_pending_operations()` methods.
|
# `lazy_model_operation()` and `do_pending_operations()` methods.
|
||||||
self._pending_operations = defaultdict(list)
|
self._pending_operations = defaultdict(list)
|
||||||
|
|
||||||
# Populate apps and models, unless it's the master registry.
|
# Populate apps and models, unless it's the main registry.
|
||||||
if installed_apps is not None:
|
if installed_apps is not None:
|
||||||
self.populate(installed_apps)
|
self.populate(installed_apps)
|
||||||
|
|
||||||
|
|
|
@ -785,7 +785,7 @@ class Client(ClientMixin, RequestFactory):
|
||||||
|
|
||||||
def request(self, **request):
|
def request(self, **request):
|
||||||
"""
|
"""
|
||||||
The master request method. Compose the environment dictionary and pass
|
Make a generic request. Compose the environment dictionary and pass
|
||||||
to the handler, return the result of the handler. Assume defaults for
|
to the handler, return the result of the handler. Assume defaults for
|
||||||
the query environment, which can be overridden using the arguments to
|
the query environment, which can be overridden using the arguments to
|
||||||
the request.
|
the request.
|
||||||
|
@ -1041,7 +1041,7 @@ class AsyncClient(ClientMixin, AsyncRequestFactory):
|
||||||
|
|
||||||
async def request(self, **request):
|
async def request(self, **request):
|
||||||
"""
|
"""
|
||||||
The master request method. Compose the scope dictionary and pass to the
|
Make a generic request. Compose the scope dictionary and pass to the
|
||||||
handler, return the result of the handler. Assume defaults for the
|
handler, return the result of the handler. Assume defaults for the
|
||||||
query environment, which can be overridden using the arguments to the
|
query environment, which can be overridden using the arguments to the
|
||||||
request.
|
request.
|
||||||
|
|
|
@ -94,8 +94,8 @@ source_suffix = ".txt"
|
||||||
# The encoding of source files.
|
# The encoding of source files.
|
||||||
# source_encoding = 'utf-8-sig'
|
# source_encoding = 'utf-8-sig'
|
||||||
|
|
||||||
# The master toctree document.
|
# The root document.
|
||||||
master_doc = "contents"
|
root_doc = "contents"
|
||||||
|
|
||||||
# General substitutions.
|
# General substitutions.
|
||||||
project = "Django"
|
project = "Django"
|
||||||
|
@ -347,7 +347,7 @@ man_pages = [
|
||||||
# description, category, toctree_only)
|
# description, category, toctree_only)
|
||||||
texinfo_documents = [
|
texinfo_documents = [
|
||||||
(
|
(
|
||||||
master_doc,
|
root_doc,
|
||||||
"django",
|
"django",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -870,9 +870,9 @@ If you\(aqre in a multi\-database setup, you might have fixture data that
|
||||||
you want to load onto one database, but not onto another. In this
|
you want to load onto one database, but not onto another. In this
|
||||||
situation, you can add a database identifier into the names of your fixtures.
|
situation, you can add a database identifier into the names of your fixtures.
|
||||||
.sp
|
.sp
|
||||||
For example, if your \fBDATABASES\fP setting has a \(aqmaster\(aq database
|
For example, if your \fBDATABASES\fP setting has a \(aqusers\(aq database
|
||||||
defined, name the fixture \fBmydata.master.json\fP or
|
defined, name the fixture \fBmydata.users.json\fP or
|
||||||
\fBmydata.master.json.gz\fP and the fixture will only be loaded when you
|
\fBmydata.users.json.gz\fP and the fixture will only be loaded when you
|
||||||
specify you want to load data into the \fBmaster\fP database.
|
specify you want to load data into the \fBmaster\fP database.
|
||||||
.SS Loading fixtures from \fBstdin\fP
|
.SS Loading fixtures from \fBstdin\fP
|
||||||
.sp
|
.sp
|
||||||
|
@ -1815,7 +1815,7 @@ zip files, you can use a URL like:
|
||||||
.sp
|
.sp
|
||||||
.nf
|
.nf
|
||||||
.ft C
|
.ft C
|
||||||
django\-admin startapp \-\-template=https://github.com/githubuser/django\-app\-template/archive/master.zip myapp
|
django\-admin startapp \-\-template=https://github.com/githubuser/django\-app\-template/archive/main.zip myapp
|
||||||
.ft P
|
.ft P
|
||||||
.fi
|
.fi
|
||||||
.UNINDENT
|
.UNINDENT
|
||||||
|
|
|
@ -18,9 +18,9 @@ MRO is an acronym for Method Resolution Order.
|
||||||
|
|
||||||
.. class:: django.views.generic.base.View
|
.. class:: django.views.generic.base.View
|
||||||
|
|
||||||
The master class-based base view. All other class-based views inherit from
|
The base view class. All other class-based views inherit from this base
|
||||||
this base class. It isn't strictly a generic view and thus can also be
|
class. It isn't strictly a generic view and thus can also be imported from
|
||||||
imported from ``django.views``.
|
``django.views``.
|
||||||
|
|
||||||
**Method Flowchart**
|
**Method Flowchart**
|
||||||
|
|
||||||
|
|
|
@ -632,10 +632,10 @@ If you're in a multi-database setup, you might have fixture data that
|
||||||
you want to load onto one database, but not onto another. In this
|
you want to load onto one database, but not onto another. In this
|
||||||
situation, you can add a database identifier into the names of your fixtures.
|
situation, you can add a database identifier into the names of your fixtures.
|
||||||
|
|
||||||
For example, if your :setting:`DATABASES` setting has a 'master' database
|
For example, if your :setting:`DATABASES` setting has a 'users' database
|
||||||
defined, name the fixture ``mydata.master.json`` or
|
defined, name the fixture ``mydata.users.json`` or
|
||||||
``mydata.master.json.gz`` and the fixture will only be loaded when you
|
``mydata.users.json.gz`` and the fixture will only be loaded when you
|
||||||
specify you want to load data into the ``master`` database.
|
specify you want to load data into the ``users`` database.
|
||||||
|
|
||||||
.. _loading-fixtures-stdin:
|
.. _loading-fixtures-stdin:
|
||||||
|
|
||||||
|
@ -1311,7 +1311,7 @@ fly.
|
||||||
For example, taking advantage of GitHub's feature to expose repositories as
|
For example, taking advantage of GitHub's feature to expose repositories as
|
||||||
zip files, you can use a URL like::
|
zip files, you can use a URL like::
|
||||||
|
|
||||||
django-admin startapp --template=https://github.com/githubuser/django-app-template/archive/master.zip myapp
|
django-admin startapp --template=https://github.com/githubuser/django-app-template/archive/main.zip myapp
|
||||||
|
|
||||||
.. django-admin-option:: --extension EXTENSIONS, -e EXTENSIONS
|
.. django-admin-option:: --extension EXTENSIONS, -e EXTENSIONS
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
pyenchant
|
pyenchant
|
||||||
Sphinx>=3.1.0
|
Sphinx>=4.0.0
|
||||||
sphinxcontrib-spelling
|
sphinxcontrib-spelling
|
||||||
|
|
|
@ -233,18 +233,18 @@ Using routers
|
||||||
|
|
||||||
Database routers are installed using the :setting:`DATABASE_ROUTERS`
|
Database routers are installed using the :setting:`DATABASE_ROUTERS`
|
||||||
setting. This setting defines a list of class names, each specifying a
|
setting. This setting defines a list of class names, each specifying a
|
||||||
router that should be used by the master router
|
router that should be used by the base router
|
||||||
(``django.db.router``).
|
(``django.db.router``).
|
||||||
|
|
||||||
The master router is used by Django's database operations to allocate
|
The base router is used by Django's database operations to allocate
|
||||||
database usage. Whenever a query needs to know which database to use,
|
database usage. Whenever a query needs to know which database to use,
|
||||||
it calls the master router, providing a model and a hint (if
|
it calls the base router, providing a model and a hint (if
|
||||||
available). Django then tries each router in turn until a database
|
available). The base router tries each router class in turn until one returns
|
||||||
suggestion can be found. If no suggestion can be found, it tries the
|
a database suggestion. If no routers return a suggestion, the base router tries
|
||||||
current :attr:`instance._state.db <django.db.models.Model._state>` of the hint
|
the current :attr:`instance._state.db
|
||||||
instance. If a hint instance wasn't provided, or :attr:`instance._state.db
|
<django.db.models.Model._state>` of the hint instance. If no hint instance
|
||||||
<django.db.models.Model._state>` is ``None``, the master router will allocate
|
was provided, or :attr:`instance._state.db <django.db.models.Model._state>` is
|
||||||
the ``default`` database.
|
``None``, the base router will allocate the ``default`` database.
|
||||||
|
|
||||||
An example
|
An example
|
||||||
----------
|
----------
|
||||||
|
|
|
@ -33,20 +33,20 @@ HERE = os.path.dirname(__file__)
|
||||||
|
|
||||||
|
|
||||||
class AppsTests(SimpleTestCase):
|
class AppsTests(SimpleTestCase):
|
||||||
def test_singleton_master(self):
|
def test_singleton_main(self):
|
||||||
"""
|
"""
|
||||||
Only one master registry can exist.
|
Only one main registry can exist.
|
||||||
"""
|
"""
|
||||||
with self.assertRaises(RuntimeError):
|
with self.assertRaises(RuntimeError):
|
||||||
Apps(installed_apps=None)
|
Apps(installed_apps=None)
|
||||||
|
|
||||||
def test_ready(self):
|
def test_ready(self):
|
||||||
"""
|
"""
|
||||||
Tests the ready property of the master registry.
|
Tests the ready property of the main registry.
|
||||||
"""
|
"""
|
||||||
# The master app registry is always ready when the tests run.
|
# The main app registry is always ready when the tests run.
|
||||||
self.assertIs(apps.ready, True)
|
self.assertIs(apps.ready, True)
|
||||||
# Non-master app registries are populated in __init__.
|
# Non-main app registries are populated in __init__.
|
||||||
self.assertIs(Apps().ready, True)
|
self.assertIs(Apps().ready, True)
|
||||||
# The condition is set when apps are ready
|
# The condition is set when apps are ready
|
||||||
self.assertIs(apps.ready_event.is_set(), True)
|
self.assertIs(apps.ready_event.is_set(), True)
|
||||||
|
|
|
@ -173,7 +173,7 @@ class LiveServerViews(LiveServerBase):
|
||||||
we can detect a content length from the response. This should be doable
|
we can detect a content length from the response. This should be doable
|
||||||
for all simple views and streaming responses where an iterable with
|
for all simple views and streaming responses where an iterable with
|
||||||
length of one is passed. The latter follows as result of `set_content_length`
|
length of one is passed. The latter follows as result of `set_content_length`
|
||||||
from https://github.com/python/cpython/blob/master/Lib/wsgiref/handlers.py.
|
from https://github.com/python/cpython/blob/main/Lib/wsgiref/handlers.py.
|
||||||
|
|
||||||
If we cannot detect a content length we explicitly set the `Connection`
|
If we cannot detect a content length we explicitly set the `Connection`
|
||||||
header to `close` to notify the client that we do not actually support
|
header to `close` to notify the client that we do not actually support
|
||||||
|
|
|
@ -1778,7 +1778,7 @@ class OverrideSettingsTests(SimpleTestCase):
|
||||||
|
|
||||||
def test_override_database_routers(self):
|
def test_override_database_routers(self):
|
||||||
"""
|
"""
|
||||||
Overriding DATABASE_ROUTERS should update the master router.
|
Overriding DATABASE_ROUTERS should update the base router.
|
||||||
"""
|
"""
|
||||||
test_routers = [object()]
|
test_routers = [object()]
|
||||||
with self.settings(DATABASE_ROUTERS=test_routers):
|
with self.settings(DATABASE_ROUTERS=test_routers):
|
||||||
|
|
Loading…
Reference in New Issue