On 10 août, 16:30, Tom Evans <[email protected]> wrote:
>
> You have two options:
Actually, three.
> you can extract the value in the view, and put it into the context
> that is used to render the template.
Simple but totally unpractical for most projects, as it requires
making ALL views duplicating this behavior.
> you can access it using dot notation [1], which is used in templates
> (templates are not python, you cannot write python in templates). Eg:
> {% url url-name request.GET.page %}
Probably the most cost-effective solution - until you have to parse
all your templates when there's any change. As a side note:
1/ you can use the "default" template filter to handle the case when
there's no 'page' key in request.GET
2/ you can use request.REQUEST if you want to work as well with GET
and POST.
Now for the third solution: write your own template tag. Not
necessarily required, but that's often the best solution wrt/
decoupling / flexibility / maintainability / reusability.
> Cheers
>
> Tom
>
> [1]https://docs.djangoproject.com/en/1.3/topics/templates/#variables
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.