URLConf:
url(r'^body/(?P<id>\d+)/$', 'body_part_detail', name='body-part-detail'), url(r'^body/(?P<id>\d+)/(?P<slug>[-\w\d]+)/$', 'body_part_detail', name='body-part-detail'),
get_absolute_url()
implementation:def get_absolute_url(self): kwargs = { 'id' : self.id, 'slug' : slugify(self.name) } return reverse('body-part-detail', kwargs=kwargs)
Now, I've got two url
s where name=body-part-detail
(which may be wrong?). Nevertheless, reverse
succeeds in the sense that it uses the second url
and returns the desired URL with the slug component. Why does this work? Am I just "lucky" in this case (quotes because programs shouldn't be lucky!)?
Finally, there are several places on SO and the Web where people give examples of URLConfs with url
s that share name
keyword arg. For example, Visgean Skeloru's answer here: Optional get parameters in django?. Is this wrong/bad?