E
E
EA-EKB2018-06-14 08:28:35
Django
EA-EKB, 2018-06-14 08:28:35

How to display EXTRA_MODEL_FIELDS in Mezzanin template?

It is not possible to display the field added via EXTRA_MODEL_FIELDS in the template.
In /mezzanine/site/site/settings.py at the end of the file added:

EXTRA_MODEL_FIELDS = (
    # Four-item sequence for one field injected.
    (
        # Dotted path to field.
        "mezzanine.pages.models.RichTextPage.header_image",
        # Dotted path to field class.
        "django.db.models.ImageField",
        # Positional args for field class.
        ("Изображение в шапке",),
        # Keyword args for field class.
        {"blank": True, "upload_to": "top_images"},
    ),
)

I output it like this in the template:
{% if page.header_image %}{{ page.header_image }}{% else %}/static/img/home/slider/2.jpg{% endif %}

The field in the admin panel is filled.
Tell me, please, what is the problem? Surely it is solved simply, but I see python for the first time.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
EA-EKB, 2018-06-15
@EA-EKB

It's decided.
I had to replace the line

"mezzanine.pages.models.RichTextPage.header_image",
on the
"mezzanine.pages.models.Page.header_image",

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question