How to use regions in custom templates

28 views
Skip to first unread message

__h__

unread,
Mar 23, 2013, 1:29:09 PM3/23/13
to django-...@googlegroups.com
So I had an existing django project, but needed to add some content to certain templates that could be edited by the user.
The path I took was to install the page module and create fake pages that hold those regions and call the programatically in
the actual view like

class HomeView(TemplateView):
    template_name = 'home.html'

    def get_context_data(self):
        k = super(HomeView, self).get_context_data()
        k.update({'page': Page.objects.get(slug='home-page')})
        return k


and then in the template call

{{ page.content.main_message.0.render }}

Is this the way to tackle this? or is there a faincms way?

Thanks in advance.

Martin J. Laubach

unread,
Mar 23, 2013, 2:14:05 PM3/23/13
to django-...@googlegroups.com
Well the canonical way to render a Page is to use the feincms_render_region template tag (ie. your example would be {% feincms_render_region page "main_message" request %}).

hernantz

unread,
Mar 23, 2013, 3:00:00 PM3/23/13
to django-...@googlegroups.com
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django FeinCMS" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-feincms/8GD2iuX6wEI/unsubscribe?hl=en-GB.
> To unsubscribe from this group and all of its topics, send an email to
> django-feincm...@googlegroups.com.
> To post to this group, send an email to django-...@googlegroups.com.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/django-feincms/-/v9DtxvuLrLIJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

thanks, that did the trick.
Reply all
Reply to author
Forward
0 new messages