Template context variables

36 views
Skip to first unread message

est

unread,
Dec 24, 2011, 6:08:47 AM12/24/11
to Django FeinCMS
Hi all,

I'm total noob in Django as well as in FeinCMS. I've installed feincms
page module and registered default content types:

Page.register_templates({
'title': _('Standard template'),
'path': 'page/page.html',
'regions': (
('main', _('Main content area')),
('sidebar', _('Sidebar'), 'inherited'),
),
})

Page.create_content_type(RichTextContent)
Page.create_content_type(ImageContent, POSITION_CHOICES=(
('block', _('block')),
('left', _('left')),
('right', _('right')),
))

Now I'm trying to create a template for this.

Can anyone say how to get page model fields in template, such as title
or slug?

Martin J. Laubach

unread,
Dec 24, 2011, 8:28:35 AM12/24/11
to django-...@googlegroups.com
The current page will be passed to the template as "feincms_page". You can then render your regions with the "feincms_render_region" template tag.

m "hohoho" jl

est

unread,
Dec 24, 2011, 9:44:17 AM12/24/11
to Django FeinCMS
Thank you a lot!

just in case if somebody needs
title can be retrieved as

{{ feincms_page.title }}

Matthias Kestenholz

unread,
Dec 24, 2011, 9:47:52 AM12/24/11
to django-...@googlegroups.com
On Sat, Dec 24, 2011 at 15:44, est <bdz...@gmail.com> wrote:
> Thank you a lot!
>
> just in case if somebody needs
> title can be retrieved as
>
> {{ feincms_page.title }}
>

Thanks for posting the solution. You might be interested in the
example base template, too:

<https://github.com/feincms/feincms/blob/master/example/templates/base.html>


Matthias

est

unread,
Dec 24, 2011, 12:54:01 PM12/24/11
to Django FeinCMS
It is vey interesting example, especally I would like to see how
frontend_editing works, thanks!

But cannot try that because I suddenly got another problem - tree
structure disappeared in pages
listing and richtext and images widgets as well. I think this is
another topic
so I opened another thread.
> <https://github.com/feincms/feincms/blob/master/example/templates/base...>
>
> Matthias

est

unread,
Dec 26, 2011, 5:20:31 AM12/26/11
to Django FeinCMS
Tried example base template, but couldn't make it work.

It gives exception

"VariableDoesNotExist while rendering: Failed lookup for key [request]
in u"[{'in_appcontent_subpage': False, 'feincms_page': <Page: test>,
'extra_path': '/'}..."

and highlights string 96:

{% block content %}{% feincms_render_region feincms_page "main"
request %}{% endblock %}


Could you please tell me what else should I configure to make this
template work?

Matthias Kestenholz

unread,
Dec 28, 2011, 4:20:41 AM12/28/11
to django-...@googlegroups.com
On Mon, Dec 26, 2011 at 11:20, est <bdz...@gmail.com> wrote:
> Tried example base template, but couldn't make it work.
>
> It gives exception
>
> "VariableDoesNotExist while rendering: Failed lookup for key [request]
> in u"[{'in_appcontent_subpage': False, 'feincms_page': <Page: test>,
> 'extra_path': '/'}..."
>
> and highlights string 96:
>
> {% block content %}{% feincms_render_region feincms_page "main"
> request %}{% endblock %}
>
>
> Could you please tell me what else should I configure to make this
> template work?
>

You need the 'request' request processor from Django itself:

<http://readthedocs.org/docs/feincms-django-cms/en/latest/templatetags.html#module-feincms.templatetags.feincms_tags>

Short version:
"This means you should add django.core.context_processors.request to
your TEMPLATE_CONTEXT_PROCESSORS."

Matthias

est

unread,
Dec 28, 2011, 11:23:02 AM12/28/11
to Django FeinCMS
That did the job, thank you!

:)


On 28 дек, 13:20, Matthias Kestenholz <m...@feinheit.ch> wrote:
> On Mon, Dec 26, 2011 at 11:20, est <bdz...@gmail.com> wrote:
> > Tried example base template, but couldn't make it work.
>
> > It gives exception
>
> > "VariableDoesNotExist while rendering: Failed lookup for key [request]
> > in u"[{'in_appcontent_subpage': False, 'feincms_page': <Page: test>,
> > 'extra_path': '/'}..."
>
> > and highlights string 96:
>
> > {% block content %}{% feincms_render_region feincms_page "main"
> > request %}{% endblock %}
>
> > Could you please tell me what else should I configure to make this
> > template work?
>
> You need the 'request' request processor from Django itself:
>
> <http://readthedocs.org/docs/feincms-django-cms/en/latest/templatetags...>
Reply all
Reply to author
Forward
0 new messages