Skip to main content

Utilities for working with dynamically loaded Django apps.

Project description

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)
  • Note: if the dynamic Django app uses WEBPACK_LOADER, keep in mind that it is important that the version of django-webpack-loader and the version of webpack-bundle-tracker be compatible. If you're using django-webpack-loader prior to version 1.0 then a known good pair of versions is django-webpack-loader==0.6.0 and webpack-bundle-tracker==0.4.3.
  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.

Developing

Making a new release

  1. Update the version in setup.cfg.

  2. Commit the update to setup.cfg.

  3. Tag the repo with the same version, with the format v${version_number}. For example, if the version number in setup.cfg is "1.2" then tag the repo with "v1.2".

    VERSION=...
    git tag -m $VERSION $VERSION
    git push --follow-tags
    
  4. In a clean checkout

    cd /tmp/
    git clone /path/to/airavata-django-portal-commons/ -b $VERSION
    cd airavata-django-portal-commons
    python3 -m venv venv
    source venv/bin/activate
    python3 -m pip install --upgrade pip build
    python3 -m build
    
  5. Push to pypi.org. Optionally can push to test.pypi.org. See https://packaging.python.org/tutorials/packaging-projects/ for more info.

    python3 -m pip install --upgrade twine
    python3 -m twine upload dist/*
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

airavata-django-portal-commons-1.0.2.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file airavata-django-portal-commons-1.0.2.tar.gz.

File metadata

File hashes

Hashes for airavata-django-portal-commons-1.0.2.tar.gz
Algorithm Hash digest
SHA256 11290eb36941c6b748e4ee9701f3c9d564aa49acc5baf2c8119269298dbbcfff
MD5 ea6c76284fd078db43cf66763d2b31bb
BLAKE2b-256 43d7ba67c79cbf8241ed7911c7aece337aafa7e5014e138c996924789e91448a

See more details on using hashes here.

File details

Details for the file airavata_django_portal_commons-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for airavata_django_portal_commons-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d589c4b72d35cdbea646efda9474e1db7084e8073b29dddf4bbafb7a4b4911fa
MD5 686a454dfa958c4acb67ffce6bcb678e
BLAKE2b-256 fb3df859e82b261bfb3355f1412306b5dacc5804fc46bc14fb8339fdf88daba8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page