views:

107

answers:

1

Hello. I am trying to do some custom things in Django comments form. I have simple tag named "get_flatpage_by_id" that returns flatpage model data as array. This is working I expected:

{% get_flatpage_by_id 14 as page %}

It's returning flatpage that ID is 14. But this is not working, if I try to pass {{ form.object_pk.data }} (that returns 14). This is how it should look like:

{% get_flatpage_by_id form.object_pk.data as page %}

Simple tag receives value "form.object_pk.data" (string), not 14. I don't know how to tell Django that "form.object_pk.data" is variable, not a string!

A: 

Nevermind, my friend showed solution...

In filter I can read all data passed to template, so I received form object and data I needed.

Remigijus
Could you please post a code snippet for this? I just came across this question looking for an answer to this problem.
Ed Brannin
In your templatetags you can access flatpage id using following syntax: context['form'].object_pk.dataAs I said before, you can access all context elements in template tag (this includes your and Django variables passed to template).
Remigijus