get_absolute_url in djano 2.1.7

16 views
Skip to first unread message

arpan godiyal

unread,
Mar 17, 2019, 10:37:27 AM3/17/19
to Django users
Can someone help me with how to use get_absolute_url method in django 2.1.7.

Ankit Anurag

unread,
Mar 17, 2019, 12:49:58 PM3/17/19
to Django users
The one major use is that this function helps you avoid situations where you have to hardcode a URL in your templates. Instead, you use something like {{<model_name>.get_absolute_url}} and even if you change the path in some way at some later point of time, it won't matter. It's basically a really good practice to use this function to define your URL.
Check out this link from Stack : https://stackoverflow.com/questions/43179875/when-to-use-django-get-absolute-url-method
Reply all
Reply to author
Forward
0 new messages