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
< 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
Post a Comment