Create urls in Django

A url is the path which we write in the urls.py file. In Django, we create a url using the path()

urlpatterns = [
    path('any_url/', views.function_name, name='urlname'),
]

So basically we are giving 3 parameters here.

  1. The first parameter is the url which will be called in the search bar of the web browser.
  2. The second parameter will be the filename(views) followed by the function name which will handle that url request.
  3. The third parameter is an optional one, it is just like a nickname given to the url. We use it in <a> tags and it will automatically call the given url in that path.

Tags: Funda of web it Django tutorials, Django tutorials, Django tutorials funda, django for beginners, how to create urls in django, how to create a path in django, how to give name for a path, how to make a url path in django,

© Copyright - 2018 - 2021 | All rights reserved at Funda of Web IT