KetanIP
Posted on December 6, 2020
This post was originally posted here π¨βπ» Routing in Django ( Part 9 ) - Django For Beginners.
This is part of the series Django For Beginners we are going to see about apps in app and we will see about urls in python.
In this post we are going to learn all about urls in django,, let's get started.
Understanding URLS in Django
Let us first understand where we write our urls, we write our urls in our project folder in urls.py
file, as shown below.
π myDjangoSite
- π myDjangoSite
- π __init__.py
- π asgi.py
- π settings.py
- π urls.py
- π wsgi.py
- π manage.py
In urls.py
specifically we write path for our django website in urlpatterns
list, in a patterns as shown below,
from django.urls import path
from . import views
urlpatterns = [
path('', views.Home, name="home"),
path('about/', views.About, name="about"),
]
The syntax for path is as follows,
path( route, view, name )
Where route is a string argument and denotes the relative path we want for that view. View is a view
it may be a class-base or a function-based view...
Sorry to interrupt you, you can read this complete post here π¨βπ» Routing in Django ( Part 9 ) - Django For Beginners.
Posted on December 6, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.