In order to handle different types of pages that require more structured content than provided by the RichTextPage
model, you can simply create your own models that inherit from Page
. For example if we wanted to have pages that were authors with books:
from django.db import models from mezzanine.pages.models import Page # The members of Page will be inherited by the Author model, such # as title, slug, etc. For authors we can use the title field to # store the author's name. For our model definition, we just add # any extra fields that aren't part of the Page model, in this # case, date of birth. class Author(Page): dob = models.DateField("Date of birth") class Book(models.Model): author = models.ForeignKey("Author") cover = models.ImageField(upload_to="authors")
Next you’ll need to register your model with Django’s admin to make it available as a content type. If your content type only exposes some new fields that you’d like to make editable in the admin, you can simply register your model using the mezzanine.pages.admin.PageAdmin
class:
from django.contrib import admin from mezzanine.pages.admin import PageAdmin from .models import Author admin.site.register(Author, PageAdmin)
Hi Larry.
You’re correct; the tutorial assumes you’re comfortable writing Django applications. In this particular instance it assumes you have an app (a top-level directory, let’s call it “authors”) and you’d add the code to “authors/models.py” and “authors/admin.py”.
I recommend you go over the official Django tutorial where you’ll create an app called “polls” and learn how to modify its model and admin definitions. That knowledge will be essential when working with Mezzanine sites. Good luck!
--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mezzanine-users/00999e73-f3da-41e3-b161-f61d13f42031%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzani...@googlegroups.com.