How to Create Route and Page in Django ?

In this tutorial im going to share how to create url and call the page in Django. I have mentioned in very easy way so follow this tutorial.

How to Install Django App

Go to inside project and create below folders

mkdir static
mkdir template

Next go to settings.py and put below code

 'DIRS': [BASE_DIR,'template'],

Next to put belw code

STATICFILES_DIRS = [
    BASE_DIR / "static",
    "/var/www/static/",
]

Next go to template folder and put below file

base.html

Next go to views.py and put below code

	def home(request):
	    # return HttpResponse("Hey I am a Developer")
	    return render(request,'base.html')

Next go to urls.py file and put below code

	from django.contrib import admin
	from django.urls import path
	from myProject.myApp.views import home  # Import the home view function
	urlpatterns = [
	    path('', home, name="home"),  # Map the root URL to the home view function
	    path('admin/', admin.site.urls),
	]

Next run below code

python manage.py runserver

Output

Hi I am Amit Kumar Thakur Experienced as s Software Developer with a demonstrated history of working in the information technology and services industry. Skilled in HTML, CSS, Bootstrap4, PHP, Laravel-9 , REST API,FB API,Google API, Youtube Api, Bitbucket,Github,Linux and jQuery. Strong engineering professional focused in Computer/Information Technology Administration and Management. Currently my profile is to Software Developer, analyze the requirement, creating frame for web application, coding and maintenance.

Related Posts

How to install django on Windows ?

What is Django ? Django is a high-level Python web framework that helps you build web applications quickly and efficiently. It’s open-source, free to use, and known…

How to Generate Sitemap in Flask APP ?

What is Sitemap ? A sitemap is a file that lists the pages of a website to inform search engines about the organization of its content. It…

Hellow Word in Flask App ?

What is Flask ? Flask is a lightweight and flexible web framework written in Python. It is designed to make getting started with web development quick and…

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x