Springlabs Django Standard

raw JSON →
0.3.5 verified Sat May 09 auth: no python

A Django extension providing standard utilities and configurations for Springlabs projects. Currently at version 0.3.5, targeting Python >=3.6. Release cadence is irregular.

pip install springlabs-django
error ModuleNotFoundError: No module named 'springlabs'
cause After upgrading to 0.3.0, the package was renamed from `springlabs` to `springlabs_django`.
fix
Uninstall old package: pip uninstall springlabs; reinstall: pip install springlabs-django. Then update all imports to use springlabs_django.
error RuntimeError: SECRET_KEY not configured
cause SpringlabsConfig requires a non-empty SECRET_KEY.
fix
Set the SECRET_KEY environment variable or pass secret_key parameter to SpringlabsConfig().
breaking Version 0.3.0 changed the module structure from `springlabs` to `springlabs_django`. Imports using the old `springlabs` prefix will fail after upgrade.
fix Update imports: replace `from springlabs import ...` with `from springlabs_django import ...`.
gotcha The `SpringlabsConfig` class requires `SECRET_KEY` to be set; if missing, a `RuntimeError` is raised.
fix Always set the `SECRET_KEY` environment variable or pass it explicitly.
deprecated The `standard_urlpatterns` function is deprecated as of 0.3.5 and will be removed in a future release.
fix Migrate to custom URL patterns or use the new `urlpatterns` module directly.

Initialize a SpringlabsConfig with environment variables.

import os
from springlabs_django import SpringlabsConfig

config = SpringlabsConfig(
    debug=os.environ.get('DEBUG', 'False') == 'True',
    secret_key=os.environ.get('SECRET_KEY', ''),
    allowed_hosts=os.environ.get('ALLOWED_HOSTS', '*').split(',')
)
print(config.as_dict())