Reputation: 131
I just started learning Django, and not able to understand that what is the actual difference between URL and path in Django.
Upvotes: 6
Views: 8934
Reputation: 472
I know that this is an older question, but to answer the question directly:
So, you should use either path() or re_path() moving forward, depending on which meets your needs.
Upvotes: 6
Reputation: 2291
Until Django 1.11 there was nothing called a path
to define app urls. Django 2.0
introduces path
as a replacement for URL
. Since you have just started with Django stick with 2.0 documentation and keep in mind that every forum you check will have solutions for older versions of Django
Upvotes: 13
Reputation: 424
HTTP URLs are defined in section 3.3 of RFC 1738:
An HTTP URL takes the form:
http://<host>:<port>/<path>?<searchpart>
Given a URL such as https://www.djangoproject.com/download/
, the path is just /download/
.
Sadly, Django often confuses paths and URLS. For example, all of the code examples for the get_absolute_url()
method in the documentation return paths, not URLs.
Some parts of Django do get it right though, such as request.path
and request.build_absolute_uri()
which use the correct terms.
Upvotes: 1