Skip to content

Commit

Permalink
docs: Add warning about loading Django settings in plugin apps (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
timmc-edx authored Aug 14, 2024
1 parent 704da9a commit 97b2803
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ Using edx-cookiecutter
^^^^^^^^^^^^^^^^^^^^^^
The simplest way to create a new plugin for edx-platform is to use the edx-cookiecutter tool. After creating a new repository, follow the instructions for cookiecutter-django-app. This will allow you to skip step 1 below, as the cookie cutter will create a skeleton App Config for you.

Warning
^^^^^^^

.. warning:: Plugin apps do not load at the usual point in Django's startup sequence. This section describes some known adverse effects of this.

Django settings are not available during module initialization in a plugin app, as the app's code is first imported before the settings module has been imported. While the following code will usually do the right thing in a Django app, it will always get the *default* value in a plugin app:

.. code:: python
from django.conf import settings
# Always returns None (when run at top level)
SOME_FEATURE = getattr(settings, 'SOME_FEATURE', None)
Instead, this initialization should be moved to the ``ready()`` method or similar.

(See `<https://github.com/openedx/edx-django-utils/issues/438>`__ for possible ways to remove this stumbling block in the future.)

Manual setup
^^^^^^^^^^^^

Expand Down

0 comments on commit 97b2803

Please sign in to comment.