diff --git a/README.rst b/README.rst index 536b154..0716754 100644 --- a/README.rst +++ b/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. diff --git a/configurations/asgi.py b/configurations/asgi.py new file mode 100644 index 0000000..da9401b --- /dev/null +++ b/configurations/asgi.py @@ -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() diff --git a/docs/cookbook.rst b/docs/cookbook.rst index 9184172..21624e5 100644 --- a/docs/cookbook.rst +++ b/docs/cookbook.rst @@ -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