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!

From: lwat...@sc-guru.com
Sent: Tuesday, May 7, 2019 11:14 AM
To: Mezzanine Users
Subject: [mezzanine-users] Newbe question on Creating Custom Content

The tutorial says:
_______________________________________________________________

Creating Custom Content Types
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)

Questions:
1) I assume the first block of code is a new .py file, called Author.py?  In 
what directory does it go?
2) The second block goes in some existing file? Which one?

I think the Tutorial assumes some knowledge of structure that I don't 
understand.

Thanks in advance for your help.

Larry
. 

-- 
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-users+unsubscr...@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.

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mezzanine-users/5cd1c140.1c69fb81.6421.aee2%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to