Registry / web-framework / optional-django

optional-django

JSON →
library0.3.0pypypi✓ verified 83d ago

Utilities for providing optional support for Django in Python packages, allowing conditional feature loading depending on whether Django is installed. Version 0.3.0 appears to be the latest; release cadence is low (last release years ago).

pip install optional-django
INSTALL
IMPORT
SIG · OPTIONAL-DJANGO
O
optional-django
web-frameworkpythonv0.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

optional_django
import optional_django
from optional_django.models import ...
Users often expect Django-like submodules; the main module is at the top level.

Basic usage: check availability and conditionally import Django components.

import optional_django # Check if Django is available print(optional_django.is_available()) # True or False # Conditionally import Django models if optional_django.is_available(): from django.db import models print('Django models available')
Debug
Known issues
gotchaThe library only checks whether Django is installed, not a specific version. If your package requires a minimum Django version, you must check separately.
fix
Use pkg_resources or importlib.metadata to check Django version independently.
affects: all
deprecatedThe library has not been updated in years and may not work with modern Django versions (e.g., 4.x, 5.x). Verify compatibility in your environment.
fix
Consider using try/except ImportError blocks instead of this library for simplicity.
affects: >=0.3.0
gotchaUsing this library does not prevent Django from being a top-level dependency. You still need to package Django in extras_require if you want optional support.
fix
Use extras_require in setup.py/setup.cfg to keep Django optional.
affects: all
Errors
Common errors & fixes
ImportError: No module named optional_django
Library not installed.
fix
Run 'pip install optional-django'.
AttributeError: module 'optional_django' has no attribute 'is_available'
Using an older version of the library.
fix
Upgrade to version 0.3.0: 'pip install --upgrade optional-django'.
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured.
Trying to use Django features without setting up Django settings.
fix
Call 'django.setup()' or set the DJANGO_SETTINGS_MODULE environment variable before using Django.
Upgrade
Version history
0.3.0latest on PyPI · released May 4, 2015
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
optional-django — pip install optional-django · libregistry