Updated README with getting started and pointer to documentation
1 file changed
tree: 4c4549643a9d69f653b2e56700c3dec711a1d370
  1. airavata_django_portal_commons/
  2. .gitignore
  3. MANIFEST.in
  4. pyproject.toml
  5. README.md
  6. setup.cfg
  7. setup.py
README.md

Airavata Django Portal Commons

Utilities for working with dynamically loaded Django apps.

Getting Started

Install this package with pip

pip install airavata-django-portal-commons

Dynamically loaded Django apps

  1. At the end of your Django server's settings.py file add
import sys
from airavata_django_portal_commons import dynamic_apps

# Add any dynamic apps installed in the virtual environment
dynamic_apps.load(INSTALLED_APPS)

# (Optional) merge WEBPACK_LOADER settings from custom Django apps
settings_module = sys.modules[__name__]
dynamic_apps.merge_settings(settings_module)
  1. Also add 'airavata_django_portal_commons.dynamic_apps.context_processors.custom_app_registry' to the context_processors list:
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ...
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                ...
                'airavata_django_portal_commons.dynamic_apps.context_processors.custom_app_registry',
            ],
        },
    },
]
  1. In your urls.py file add the following to the urlpatterns
urlpatterns = [
    # ...
    path('', include('airavata_django_portal_commons.dynamic_apps.urls')),
]

Creating a dynamically loaded Django app

See https://apache-airavata-django-portal.readthedocs.io/en/latest/dev/custom_django_app/ for the latest information.

Note that by default the cookiecutter template registers Django apps under the entry_point group name of airavata.djangoapp, but you can change this. Just make sure that when you call dynamic_apps.load that you pass as the second argument the name of the entry_point group.