PageRenderTime 21ms CodeModel.GetById 18ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/feincms/module/page/admin.py

http://github.com/feincms/feincms
Python | 36 lines | 22 code | 8 blank | 6 comment | 1 complexity | fd6f494ae0f4e1d9a3773b361cb97a16 MD5 | raw file
 1# ------------------------------------------------------------------------
 2# coding=utf-8
 3# ------------------------------------------------------------------------
 4
 5from __future__ import absolute_import, unicode_literals
 6
 7from django.contrib import admin
 8from django.core.exceptions import ImproperlyConfigured
 9
10from feincms import ensure_completely_loaded, settings
11from .models import Page
12from .modeladmins import PageAdmin
13
14try:
15    from django.core.exceptions import FieldDoesNotExist
16except ImportError:  # Django<1.8
17    from django.db.models import FieldDoesNotExist
18
19# ------------------------------------------------------------------------
20
21if settings.FEINCMS_USE_PAGE_ADMIN:
22    ensure_completely_loaded()
23    try:
24        Page._meta.get_field("template_key")
25    except FieldDoesNotExist:
26        raise ImproperlyConfigured(
27            "The page module requires a 'Page.register_templates()' call "
28            "somewhere ('Page.register_regions()' is not sufficient). "
29            "If you're not using the default Page admin, maybe try "
30            "FEINCMS_USE_PAGE_ADMIN=False to avoid this warning."
31        )
32
33    admin.site.register(Page, PageAdmin)
34
35# ------------------------------------------------------------------------
36# ------------------------------------------------------------------------