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.
- The first parameter is the url which will be called in the search bar of the web browser.
- The second parameter will be the filename(views) followed by the function name which will handle that url request.
- 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 - 2023 | All rights reserved at Funda of Web IT