Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 June 21, 2010 22:06:59

Sells, F.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

How to map url **kwargs


First I'm new 2 django and have made rapid progress building my app
based on the tutorial. As soon as I get it a little better, I'll clean
it up and remove the "mysite/polls" references.

I have a series of url's like this

/mysite/myapp/datagrid/clients?letter=A
/mysite/myapp/datagrid/reports
/mysite/myapp/datagrid/reports?client=LA12345
/mysite/myapp/datagrid/stores/userid=mary

I would like to map these to the same view.py method

def datagrid(request, gridtype, **options):
#where gridtype is one of clients, reports, stores
#And options contains any parameters in the URL


I would like to NOT define the legal options in the URL, because that
gives me two places to define them (3 if you count the client) and
frankly I'm not that skilled at regex. I've gotten this far, which maps
the gridtype, but cannot get the parameters, even if I explicitly name
them. Can someone explain what I'm doing wrong?

Mysite/polls/urls.py contains
urlpatterns = patterns('mysite.polls.views',
(r'^datagrid/(*)/', 'datagrid'),
...
)

And mysite/urls.py contains

urlpatterns = patterns('',
(r'^myapp/', include('mysite.polls.urls') ),
)

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

Offline

Board footer

Moderator control

Enjoy the 15th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support