I finally went half and half here, by posting to an /vote/<model_id>/
url. Personally, I think handling the GET in the tag and the POST in a
view is a bit messy, but perhaps I find a better solution later.
After I got that to work properly, I also implemented an ajax version.
I have never done that in Django before, is there some sort of
standard procedure for doing that? I posted to the same view with
an .is_ajax() clause, perhaps it's preferred to have a separate view
handling ajax calls? Either way, it worked after I figured out some
jQuery stuff (I'm a total n00b with that!).

The reasons I'm doing this instead of just grabbing django-voting, is
1. to learn! and 2. I wanted to use cookies instead of IP address (it
would be a shame if only one person in a whole office sharing the same
IP could vote, right?) or have everyone creating a user object just
for that.

Thanks all for chiming in with good advices! This is such a great
community!
/Martin

On May 14, 10:41 am, Tom Evans <tevans...@gmail.com> wrote:
> On Thu, May 13, 2010 at 6:11 PM, marty3d <martin.kjellb...@gmail.com> wrote:
> > Thanks, that's a shame...
> > So I'm now trying to do the request.POST stuff in a view instead.
> > Since the idea is to have the voting app as decoupled as possible, is
> > there a slick way to pass, perhaps the whole object in this case, but
> > at least the name of the model or similar together with the post?
>
> > Thanks!
> > /Martin
>
> I can think of three options off the top of my head:
>
> 1) Have the voting app always submit to one view, regardless of the
> current view. The voting app form could include a 'next' parameter,
> indicating where to send the user back to.
>
> 2) Write the form processing code as a middleware. If you dont want
> every page to handling posting this voting app form, use the
> decorator_from_middleware adapter to turn your middleware into
> something you can decorate specific views with.
>
> 3) Handle posts from the voting app with AJAX, always posting to the
> same page, and updating the displayed content in the page when done.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to