Django 1.7 has introduced a new way for handling application configuration that is independent of models.py
. However the method for using the new AppConfig
requires this line:
from django.apps import AppConfig
Unfortunately, this will break in Django 1.6 as there is no apps
module.
Is it possible to have an app be compatible with 1.6 and 1.7 using conditional imports, or is it a matter of split code bases? If so, are is there a recommend guide, preferably from the Django developers on how to do so?
How about using AppConfig only if django version >= 1.7 (take that into account in __ init __.py file too):
# myapp/apps.py
from django import VERSION as DJANGO_VERSION
if DJANGO_VERSION >= (1, 7):
from django.apps import AppConfig
class MyAppConfig(AppConfig):
...
# myapp/__init__.py
from django import VERSION as DJANGO_VERSION
if DJANGO_VERSION >= (1, 7):
default_app_config = 'myapp.apps.MyAppConfig'