0% found this document useful (0 votes)
15 views7 pages

Steps To Build A Website On Django

Uploaded by

patilsiddeshb16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views7 pages

Steps To Build A Website On Django

Uploaded by

patilsiddeshb16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Steps to build a website on Django

First install Django using – pip install Django command on powershell

Create a virtual env using the command - python -m venv venv


Start a project using – django-admin startproject title/
python -m django startproject mysite

after creating project, Django will defaultly create some project files

Close the vs code and open the Project file(Hello in this case).

Run the command – python manage.py runserver to check if Django has been successfully
downloaded.
A Django project can contain more than one apps but it should at least contain one app.

Now create an app using command – python manage.py startapp appname.

After creating an app . make a urls.py file in the app(home).

Copy the content of urls.py from the main project-app to your urls.py of recently created app(home
app).

Now add a home path to your urls.py in your project-app(Hello)


Create a path in app(home)->urls.py

After creating the path, define a view(function) that returns a template or a string.
In this way, a simple string/webpage will be displayed on screen

How it works -

This port goes to Hello project’s -> urls.py

It follows the path home.urls


Then it goes to views.index .

In this way the views function returns a string or it can also return a template.

So the path is:-


ProjectApp.urls -> newApp.urls -> newApp.views -> views.functions

Static files- it is that file which is publicly available so it doesn’t contain any sensitive data.

Store all the static files in a static folder.

--------------------------------------------------------------------------------------------------------------------------------------

Templates-

In order to access templates add BASE_DIR / “Templates” to DIRS of template in settings.py of


Project App.

Place all the templates in the template folder.


In oder to render a template just use render() function which has required parameters- render and
template_name. context is an optional parameter.

You might also like