get absolute url
from django.urls import reverse
def get_absolute_url(self):
return reverse('your:url', kwargs={'pk': self.pk})
get absolute url
from django.urls import reverse
def get_absolute_url(self):
return reverse('your:url', kwargs={'pk': self.pk})
get_absolute_url method
First of all, when it comes to web development you really want to avoid hard coding paths in your templates. The reason for this is that paths might change, and it will be a hassle to go through all your HTML and templates to find every single URL or path and update it manually. It makes your code much harder to maintain.
The solution to this is to define functions that return the URL instead. This is where get_absolute_url() comes into the picture.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us