Django URLs - Named URLS, url template-tag, Reversing URLs, URL namespaces, & get_absolute_url()

preview_player
Показать описание
In this video we'll dive into some core URL-related concepts in Django. We'll see how to give our URLs names that can then be used in other Django utilities.

We'll see how to use these with the "url" template-tag to generate links in our Django templates, and with the reverse() function for building URLs in our Python code.

We'll also see how to namespace URLs in applications within our Django project, and how to refer to these namespaced URLs with the above tools.

Finally, we'll demonstrate use of the get_absolute_url() function in Django - a model method that should return the canonical URL for an object in your database.

BONUS: we'll see the django-extensions "show_urls" command to get command-line information on the URLs in use in our project (including third-party URLs).

📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
00:00 Intro
01:25 Adding Navbar with hard-coded links
05:08 Generating links with the URL template-tag
06:23 Adding Booklist with dynamic URL parameter
09:41 Using named URLs with the reverse() function
13:55 Namespacing URLs in Django
19:39 get_absolute_url() Model Function
23:05 django-extensions show_urls command

☕️ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲:
To support the channel and encourage new videos, please consider buying me a coffee here:

▶️ Full Playlist:

𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:

#django #python
Рекомендации по теме
Комментарии
Автор

This is the best tutorial I have ever seen.

Man-sixf
Автор

You're hands down the best Django channel ever. Your explanations are on point, easy to follow and easy to remember. I wholeheartedly wish to see you grow on this platform. I've recently done a uni project which couldn't have been done without your many so tutorials. Just wanted to let you know you're changing lives sir.

yaboi
Автор

Very informative, thank you. Your videos are very detailed and precise just like official docs. Looking forward to learn more django stuff from the channel.

ghostrpg
Автор

Very good and clear way of explaining those concepts, thank you for the video !

jordib.
Автор

I'm absolutely thrilled to have discovered this channel! The content provided here has been an incredible source of knowledge and insight for me. I cannot express enough how appreciative I am for the clarity and precision with which you explain various topics. Your explanations are truly exceptional and remarkably accurate, always hitting the mark and leaving no room for confusion. It's truly refreshing to come across such high-quality explanations that resonate so perfectly with what I'm seeking to understand. Thank you for creating such an invaluable resource that consistently delivers top-notch explanations.

olumideibilaiye
Автор

Great, please continue with this type of lessons, short but very pedagogical.

peterholzer
Автор

Brilliantly explained, thank you! I'm going to watch all of your videos now :)

mrvalvet
Автор

Fantastic video as usual.
One question: do you ever use the namespace in the include function? In which case?

Thanks.

MagnusAnand
Автор

Everything is good. But is there anything in django by which we can protect our urls.
Like for example: if the user changes the url from pk 7 to pk 8, then he should not get the info about the book with pk 8.

sambhrammathad
Автор

I really struggle with naming things. I’m sure everyone has returned to a project months after finishing and then have to decipher what you were thinking when you named something 🤦🏻

kodeypatterson
welcome to shbcf.ru