简体   繁体   中英

Placeholder Fields - Django CMS

I can't get those placeholder fields to work.

This is my model:

    class Category(models.Model):
        class Meta:
             verbose_name = "Kategorie"
             verbose_name_plural = "Kategorien"
        header = PlaceholderField('header')

And this is my views:

    def rooms_list(request):
    categories = Category.objects.all()

    return render(request, "rooms/rooms-list.html", locals())

If I know try to render it like so:

   {% render_placeholder category.header %}

Nothing happens at all...

Thanks in advance!

I don't see all your code but, in the template do you do a loop over your categories?

something like

{% for category in categories %}
    {% render_placeholder category.header %}
{% endfor %}

also, check if {{ categories }} is available by rendering it out just like that.

add this to the top of the template {% load cms_tags %} and do the rendering as I have added above.

If i render it out, I get: <QuerySet [<Category: test>]>

And no, I dont use a loop.

This is my admin.py:

    class CategoryAdmin(PlaceholderAdminMixin, admin.ModelAdmin):
    class Meta:
    model = Category
    fields = "__all__"


    admin.site.register(Category, CategoryAdmin)

But also I can not see something about the placeholder in the frontend... weird

Thank you very much for your quick response.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM