Django Nine

0.2.7 · maintenance · verified Fri Apr 17

django-nine is a lightweight utility library for Django that provides consistent methods for checking Django and Python versions, as well as abstracting user model access for cross-version compatibility. The current version is 0.2.7. Its release cadence is very slow, with the last update in late 2022.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `django-nine` to check the Django version and access the user model. The `versions` module provides boolean constants for easy version comparisons.

from nine import versions
from nine import user
import django

print(f"Current Django version: {django.get_version()}")

if versions.DJANGO_GTE_1_7:
    print("Django version is 1.7 or greater.")

if versions.DJANGO_GTE_2_0:
    print("Django version is 2.0 or greater.")

# Example of getting user model for cross-version compatibility
# (Requires Django to be configured, typically inside a Django project)
# from django.conf import settings
# settings.configure() # Only for standalone script, not a real Django project
# try:
#    User = user.get_user_model()
#    print(f"User model: {User._meta.label}")
# except Exception as e:
#    print(f"Could not get user model: {e}")

view raw JSON →