19👍
✅
Give urls names:
from django.urls import reverse
urlpatterns = patterns('',
url(r'^$',JobList.as_view(), name='joblist'),
url(r'^(?P<pk>\d+)/$', JobDetail.as_view(), name='jobdetail'),
)
Use that name when call reverse
:
return reverse('jobdetail', args=[self.pk])
or
return reverse('jobdetail', kwargs={'pk': self.pk})
Source:stackexchange.com