Created
August 23, 2012 15:08
-
-
Save pelagisk/3437556 to your computer and use it in GitHub Desktop.
Example mezzanine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# admin.py: | |
from copy import deepcopy | |
from django.contrib import admin | |
from mezzanine.pages.admin import PageAdmin | |
from mezzanine.pages.models import Page | |
from .models import ProjectPage | |
my_page_fieldsets = deepcopy(PageAdmin.fieldsets) | |
my_page_fieldsets[0][1]["fields"] += ("thumbnail",) | |
class MyPageAdmin(PageAdmin): | |
fieldsets = my_page_fieldsets | |
admin.site.unregister(Page) | |
admin.site.register(Page, MyPageAdmin) | |
admin.site.register(ProjectPage, MyPageAdmin) | |
# models.py: | |
from django.db import models | |
from mezzanine.pages.models import Page | |
from mezzanine.core.models import RichText | |
from django.utils.translation import ugettext_lazy as _ | |
# (example model, excluded irrelevant extra fields for now..) | |
class ProjectPage(Page, RichText): | |
class Meta: | |
verbose_name = _("Project page) | |
verbose_name_plural = _("Project pages") | |
# from settings.py: | |
EXTRA_MODEL_FIELDS = ( | |
( | |
"mezzanine.pages.models.Page.thumbnail", | |
"ImageField", | |
("Thumbnail image",), | |
{"null": True, "blank": True, "upload_to": "thumbs"}, | |
), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment