from news import views
path('archive/', views.archive, name='news-archive')
from django.urls import reverse
reverse('news-archive')
# Можно так:
def get_absolute_url(self):
return "/people/%i/" % self.id
# Но лучше так:
def get_absolute_url(self):
from django.urls import reverse
return reverse('people.views.details', args=[str(self.id)])
<a href="{{ object.get_absolute_url }}">{{ object.name }}</a>
<!-- Так не надо делать -->
<a href="/language/category/product/{{product.pk}}">Link</a>
<!-- надо так -->
<a href="{{product.get_absolute_url}}">Link</a>
urlpatterns = [
path('articles/<int:year>/<int:month>/<int:day>/', views.day_archive, name='day_archive'),
...
]
def ...
year = request.POST.get("year")
month = request.POST.get("month")
day = request.POST.get("day")
return HttpResponseRedirect('articles/' + year + '/' + month + '/' + day + '/')
from django.urls import reverse
def ...
year = request.POST.get("year")
month = request.POST.get("month")
day = request.POST.get("day")
return HttpResponseRedirect(reverse('day_archive', args=[year, month, day]))