mirror of
https://github.com/jazzband/django-configurations.git
synced 2026-03-16 22:20:27 +00:00
Merge pull request #291 from jazzband/feature/asgi
This commit is contained in:
commit
df51535afc
3 changed files with 24 additions and 3 deletions
17
README.rst
17
README.rst
|
|
@ -81,7 +81,7 @@ command line option, e.g.
|
|||
python manage.py runserver --settings=mysite.settings --configuration=Dev
|
||||
|
||||
To enable Django to use your configuration you now have to modify your
|
||||
**manage.py** or **wsgi.py** script to use django-configurations's versions
|
||||
**manage.py**, **wsgi.py** or **asgi.py** script to use django-configurations's versions
|
||||
of the appropriate starter functions, e.g. a typical **manage.py** using
|
||||
django-configurations would look like this:
|
||||
|
||||
|
|
@ -120,5 +120,18 @@ The same applies to your **wsgi.py** file, e.g.:
|
|||
Here we don't use the default ``django.core.wsgi.get_wsgi_application``
|
||||
function but instead ``configurations.wsgi.get_wsgi_application``.
|
||||
|
||||
Or if you are not serving your app via WSGI but ASGI instead, you need to modify your **asgi.py** file too.:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import os
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
|
||||
os.environ.setdefault('DJANGO_CONFIGURATION', 'DEV')
|
||||
|
||||
from configurations.asgi import get_asgi_application
|
||||
|
||||
application = get_asgi_application()
|
||||
|
||||
That's it! You can now use your project with ``manage.py`` and your favorite
|
||||
WSGI enabled server.
|
||||
WSGI/ASGI enabled server.
|
||||
|
|
|
|||
8
configurations/asgi.py
Normal file
8
configurations/asgi.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
from . import importer
|
||||
|
||||
importer.install()
|
||||
|
||||
from django.core.asgi import get_asgi_application # noqa: E402
|
||||
|
||||
# this is just for the crazy ones
|
||||
application = get_asgi_application()
|
||||
|
|
@ -182,7 +182,7 @@ probably just add the following to the **beginning** of your settings module:
|
|||
import configurations
|
||||
configurations.setup()
|
||||
|
||||
That has the same effect as using the ``manage.py`` or ``wsgi.py`` utilities.
|
||||
That has the same effect as using the ``manage.py``, ``wsgi.py`` or ``asgi.py`` utilities.
|
||||
This will also call ``django.setup()``.
|
||||
|
||||
>= 3.1
|
||||
|
|
|
|||
Loading…
Reference in a new issue