Monday, November 1, 2010

Re: django-voting url pattern

On Nov 1, 1:23 pm, Sithembewena Lloyd Dube <zebr...@gmail.com> wrote:
> Hi all,
>
> I have django-voting installed and am trying to get through the 'recipe'.  I
> have a url pattern which (I expect) should route voting actions to a view.
>
> Problem is, which view or views should handle this? The URL pattern is as
> follows:
>
>      (r'^videos/(?P<object_id>\d+)/(?P<direction>*up|down|clear)*vote/?$',
> vote_on_object, video_dict),
>
> I can see that object_id is being trapped as a parameter, but what is the
> italicised/ bold section doing and what URL do I then get out of it? In
> other words, I cannot decide what the view/s to handle the URL should be.
>
> Thanks,
>
> --
> Regards,
> Sithembewena Lloyd Dubehttp://www.lloyddube.com

That constrains the acceptable values of `direction` to one of 'up',
'down' or 'clear'. Any other value there will mean the URL isn't
matched.

So the URL is, for example:
/videos/1/upvote/
/videos/1/downvote/
/videos/1/clearvote/

and the view will have parameters of object_id 1 and direction up,
down or clear.
--
DR.

--
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