On Jan 17, 2008 7:19 AM, sector119 <[EMAIL PROTECTED]> wrote:
> I decide to create delete_many view and I want to pass dynamic number
> of args to it using urls:
>
> /streets/street/1/delete/
> /streets/street/12/3/4/delete/
> /streets/street/7/12/43/98/192/delete/
>
> what regexp in urls.py an view definition have I to use in my
> situation?
>
> view definition, I think, have to be something like:
> def delete_many(request, *args, **kwargs):
>     ...
>
> but how to write url regexp?

I'd recommend something like this for your regex:

^streets/street/(?P<id_list>(?:[0-9]+/?)*)/delete/

That will pull in all the numbers as a single string, since you can't
have an arbitrary number of groups in regular expressions. In your
view, you just split them apart, like so:

def view(request, id_list):
    id_list = map(int, id_list.split('/'))
    # You now have a list of IDs passed to the view

Hope that helps.

-Gul

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to