python - Django generic views with multiple parameters -


Is it possible to use normal view with additional parameters in URL mapping - that is, I found the following model:

Root of class (models.Model): area = model. Exotic (region) slug = models.SlugField (tap = true, empty = true) @model Statue def get_absolute_url (self): Return ('url-mapping:
    

code> url (r' ^ (? P & lt; Area & gt; [- \ w] +) / (? P> slug & gt; [- \ w] +) / $ ',' routes.views.route_details ', name =' route_details <

Def path_details (auto, area, slug): route = get_object_or_404 (root, slug = slug) returns render_to_response ("route / route_ command html" , {'Route': route})

As you can see, I'm actually identifying the bus route through route slags and To resize the slug bus URL (e.g., routes / central-park / mouse rock ). Can I do the same using a normal view?

Sure, something like this:

  url (r '^ (? P & lt; area & Gt; [- \ w] +) / (? P & lt; slug & gt; [- \ w] +) / $ ',' django.views.generic.list_detail .object_detail ', {' queryset ': routout .objects.all ()} name = 'route_details')  

Just work.

Be sure to either set Template_object_name to "route" or "object" in the template.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -