This is an automated email from the ASF dual-hosted git repository. machristie pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/airavata-django-portal-commons.git
commit 2da373b2a4f78c1da9783ec1802e276cfc49beb0 Author: Marcus Christie <[email protected]> AuthorDate: Tue Nov 1 12:28:47 2022 -0400 Updated README with getting started and pointer to documentation --- README.md | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 48cd3b0..0cbda17 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,65 @@ Utilities for working with dynamically loaded Django apps. ## Getting Started -TODO +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 + +```python +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) +``` + +2. Also add + `'airavata_django_portal_commons.dynamic_apps.context_processors.custom_app_registry'` + to the context_processors list: + +```python +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', + ], + }, + }, +] +``` + +3. In your urls.py file add the following to the urlpatterns + +```python +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](https://github.com/machristie/cookiecutter-airavata-django-app) +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.
