0% found this document useful (0 votes)
25 views

1 Install Django and Django Create Project

Uploaded by

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

1 Install Django and Django Create Project

Uploaded by

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

Install Django

and Django
Create Project
1
Django
• Django is a back-end server side web framework.
• Django is free, open source and written in Python.
• Django makes it easier to build web pages using Python.
• Django is a Python framework that makes it easier to
create web sites using Python.
• Django takes care of the difficult stuff so that you can
concentrate on building your web applications.
install Django
• To install Django, you must have Python installed, and a
package manager like PIP.
• Check
• python –version
• pip –version
• If you do not have PIP installed, you can download and
install it from this page: https://pypi.org/project/pip/
Create Virtual Environment
• It is suggested to have a dedicated virtual environment for each Django
project, and one way to manage a virtual environment is venv, which is
included in Python.
• The name of the virtual environment is your choice, here we will call it
myworld.
• Type the following in the command prompt, remember to navigate to
where you want to create your project:
• Windows:
• py -m venv sample

• Unix/MacOS:
• python -m venv sample
Create Virtual Environment
• This will set up a virtual environment, and create a folder named "myworld" with subfolders
and files, like this:
• sample
• Include
• Lib
• Scripts
• pyvenv.cfg
• Then you have to activate the environment, by typing this command:
• Windows:
• sample\Scripts\activate.bat
• Unix/MacOS:
• source sample/bin/activate
Create Virtual Environment
• Once the environment is activated, you will see this result in the
command prompt:

• Windows:

• (myworld) C:\Users\Your Name>


• Unix/MacOS:

• (myworld) ... $
Install Django
• Django is installed using pip, with this command:
• Windows:
• (myworld) C:\Users\Your Name>py -m pip install Django

• Unix/MacOS:
• (myworld) ... $ python -m pip install Django
Django Create Project

• Once you have come up with a suitable name for your Django project, like mine: my_project,
navigate to where in the file system you want to store the code (in the virtual environment), I
will navigate to the myworld folder, and run this command in the command prompt:
• django-admin startproject sample

• Django creates a my_project folder on my computer, with this content:


• sample
• manage.py
• sample/
• __init__.py
• asgi.py
• settings.py
• urls.py
• wsgi.py
Django Create Project
• A Django project contains the following packages and files.
The outer directory is just a container for the application. We
can rename it further.
• manage.py: It is a command-line utility which allows us to
interact with the project in various ways and also used to
manage an application.
• A directory (djangpapp) located inside, is the actual
application package name.
• Its name is the Python package name which we'll need to
use to import module inside the application.
• __init__.py: It is an empty file that tells to the Python that
this directory should be considered as a Python package.
Django Create Project
• settings.py: This file is used to configure application
settings such as database connection, static files linking
etc.
• urls.py: This file contains the listed URLs of the
application. In this file, we can mention the URLs and
corresponding actions to perform the task and display
the view.
• wsgi.py: It is an entry-point for WSGI-compatible web
servers to serve Django project.
Run the Django Project
• Now that you have a Django project, you can run it, and see what it looks
like in a browser.

• Navigate to the /sample folder and execute this command in the


command prompt:

• py manage.py runserver

• Open a new browser window and type 127.0.0.1:8000 in the address


bar.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy