I don't know that it's "bad behaviour" to use it. In my experience,
it's been unreliable, so if you're using it to do something important
(i.e. other than logging), it's not a bad idea to check whether it's
empty and have a default value as a backup.
I'll definitely look up context processors -
> The problem is that if I'm putting polls on every page of the blog,
> then I have to change each URL in the urlconf to optionally include a
> has_voted variable, right (since I'm returning people to their
> originating page via a redirect, not via the POST request itself)?
In this case, you can
The problem is that if I'm putting polls on every page of the blog,
then I have to change each URL in the urlconf to optionally include a
has_voted variable, right (since I'm returning people to their
originating page via a redirect, not via the POST request itself)?
Unless I'm going to store it
Mmm... you are writting your current view. So just add a variable
"has_voted" that will be true if the IP (or user) has voted.
I don't know if you are using the poll version of the tutorial or
mine. If you are using the version of the tutorial, you might be
interested in this, where I added
Guillermo -
Thanks again for your help - this is working really well.
I have a followup question - I don't know if you can help with this:
My custom tag embeds the current path as a hidden field in the poll
voting form, and I've modified my vote view to redirect to that path if
it's included
Oh, cool - thank you for the links, I'll be bookmarking those!
--~--~-~--~~~---~--~~
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
Custom template tags... I knew I was missing something. Thanks!
--~--~-~--~~~---~--~~
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
You can find the actual code here. For the template tag:
http://svn.guindilla.eu:8000/guindilla/trunk/guindilla/polls/templatetags/guindilla_polls.py
Fo the html:
http://svn.guindilla.eu:8000/www_guindilla_eu/templates/guindilla/polls/open_polls.html
And for how to use it:
Okay, say I've got the Django tutorial poll app, and a blog app I've
just whipped up, as separate "apps" in the same Django "site". If I
wanted to display a poll / results in the blog sidebar, is there a
straightforward way to do that, or would I have to combine the two into
a single app?
The easiest way, for your example case, would be to make sure that the
poll app makes the poll/results available in the form of custom
template tags. Then just embed these custom tags in your blog
template's sidebar and you are done.
--~--~-~--~~~---~--~~
You
10 matches
Mail list logo