From the course: Introduction to Django
Unlock this course with a free trial
Join today to access over 25,100 courses taught by industry experts.
URLs - Django Tutorial
From the course: Introduction to Django
URLs
- So now let's talk about URLs. We have looked already at defining your URLs in your urls.py, but you can actually do something called reversing a URL, which is getting a URL by its name. So given this simple URL's pattern, you are specifying the name profile, and this is inside of the user's app. So then in your Python files, if you wanted to get the URL, you could use the reverse function from Django URLs and then pass in the app name and then the name of the specific path, and this would return the URL path for it. Similarly, if you're in an HTML file and you want to get the path, then you can use the URL template tag here, pass in a string of the app, and then the specific name for the path, and that would give you this URL path, and then you could use that in your links, for example. So in this way, your URL config is specifying that this name points to this view function, and these paths that they're actually pointing to can change, and you can change them without worrying about…
Contents
-
-
-
-
-
-
(Locked)
Django architecture10m 45s
-
(Locked)
Django project structures6m 55s
-
(Locked)
Example project overview7m 53s
-
(Locked)
Deployment settings16m 17s
-
(Locked)
Django ORM: Models10m 10s
-
(Locked)
Django ORM: Queries15m 39s
-
(Locked)
Django ORM: Migrations5m 19s
-
(Locked)
The user model7m 37s
-
(Locked)
URLs8m 50s
-
(Locked)
Views11m 20s
-
(Locked)
Class-based views3m 38s
-
(Locked)
Admin8m 19s
-
(Locked)
Front end5m 14s
-
(Locked)
Templates8m 7s
-
(Locked)
Forms8m 17s
-
(Locked)
-