1 Install Django and Django Create Project
1 Install Django and Django Create Project
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) ... $
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
• py manage.py runserver