Is there a way to inject a featured image field in Mezzanine / Django RichTextPage's model? I need get a image, to specific pages in "richtextpage.html" template, but these are different from blogPost models that have a featured image field.
[SOLVED] The problem: I was trying to register/unregister a new field in Page model instead RichTextPage, changing the references got the expected result;
# settings.py
EXTRA_MODEL_FIELDS = (
(
"mezzanine.pages.models.Page.page_image",
"ImageField",
("Featured Image",),
{"blank": True, "upload_to": "uploads", },
), ...
# application admin.py
from copy import deepcopy
from mezzanine.pages.admin import PageAdmin
from mezzanine.pages.models import RichTextPage
(...)
pages_fieldsets = deepcopy(PageAdmin.fieldsets)
pages_fieldsets[0][1]["fields"].insert(-2, "page_image")
pages_fieldsets[0][1]["fields"].insert(-3, "content")
class CustomPageAdmin(PageAdmin):
fieldsets = pages_fieldsets
admin.site.unregister(RichTextPage)
admin.site.register(RichTextPage, CustomPageAdmin)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.