Maybe you can use template inheritance and have the base template access the data through, alternatively, template filters or instance methods?
To make those work, you can take advantage of the existing template processors (notably the auth one).
If you want to not have the topnav on a particular page, you can put it in a block and replace the block with nothing.
Le 3 oct. 2011 01:07, "Victor Hooi" <victorhooi@gmail.com> a écrit :
> heya,
>
> This SO post seems to suggest that data and template tags shouldn't mix...
>
> http://stackoverflow.com/questions/5046046/where-put-database-interaction-in-django-templatetags
>
> Not sure how I feel about that myself - I see the philosophical argument
> behind it, but I don't see another more efficiently creating common page
> elements (like my category dropdowns).
>
> Also, if you look at James Bennett's posts here:
>
> http://www.b-list.org/weblog/2006/jun/07/django-tips-write-better-template-tags/
>
> His code actually *does* interact with the database, as does the blog post
> here
> (http://www.webmonkey.com/2010/02/use_templates_in_django/#Roll_your_own_template_tags).
>
> Also, as an aside, each link on our category dropdown is bound to a JS click
> event - not sure how this would tie in with the custom template tag -
> separate tag for that part of it?
>
> Cheers,
> Victor
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/9cYeQwELEYsJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
-- > heya,
>
> This SO post seems to suggest that data and template tags shouldn't mix...
>
> http://stackoverflow.com/questions/5046046/where-put-database-interaction-in-django-templatetags
>
> Not sure how I feel about that myself - I see the philosophical argument
> behind it, but I don't see another more efficiently creating common page
> elements (like my category dropdowns).
>
> Also, if you look at James Bennett's posts here:
>
> http://www.b-list.org/weblog/2006/jun/07/django-tips-write-better-template-tags/
>
> His code actually *does* interact with the database, as does the blog post
> here
> (http://www.webmonkey.com/2010/02/use_templates_in_django/#Roll_your_own_template_tags).
>
> Also, as an aside, each link on our category dropdown is bound to a JS click
> event - not sure how this would tie in with the custom template tag -
> separate tag for that part of it?
>
> Cheers,
> Victor
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/9cYeQwELEYsJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment