DJANGO

Installation of Python 
Download Python from the following website
https://www.python.org/downloads/

python-3.9.0-amd64.exe will be downloaded. Double click on it to install. 

After installation go to command prompt and check python is installed or not?

C:\Users\student>python
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

">>>" This symbol is command prompt for python interpreter.
To exit from python beside command prompt type "exit()" and press enter key.

To check the version of python issue the following command.
C:\Users\student>python --version
Python 3.9.0

Installation of Django
Go to command prompt and issue the following command.
C:\Users\student>pip install django

This above command installs "Django" software along with several packages.

After installation check its version with the following command.

C:\Users\student>python -m django --version
3.1.3

Creating First Web Application Using Django
To create a web application, first we need to create a project.

Procedure to create a Project
Assume that you are in "D" drive and "Gurujang" folder.

1) D:\Gurujang>django-admin startproject Guruproject

Note1:
Now a folder named "Guruproject" will be created inside "D:\Gurujang".
Inside "D:\Gurujang\Guruproject"
same folder named "Guruproject" and a file named "manage.py" will be created.

Note2:
Again "D:\Gurujang\Guruproject\Guruproject" contains the following important files.


2)Now inside "Guruproject" we have to create app.

D:\Gurujang>cd Guruproject
D:\Gurujang\Guruproject>

Command to create App
D:\Gurujang\Guruproject>python manage.py startapp GuruApp

Note1:
With the above command "GuruApp" will be created inside D:\Gurujang\Guruproject.
Note2:
D:\Gurujang\Guruproject\GuruApp Contains following important files.
      __init__, "admin.py", "models.py", "views.py"







  




3) Now make an entry "GuruApp" in the follwing location. In the file    D:\Gurujang\Guruproject\Guruproject\settings.py.

"GuruApp" should be added to "INSTALLED_APPS" section of "settings.py"

Ex: settings.py
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'GuruApp'
]

Now Project is Ready, To know that project is running or not , First we need to start the "server".
Command to start / run the server

D:\Gurujang\Guruproject>python manage.py runserver

You will find the following screen after "Starting the Server"






















4) Now open any browser(Ex: Google Chrome / IE ) and give the URL we are viewing in the server
    Type the URL http://127.0.0.1:8000/ in the browser followed by enter key.

If you see the following screen, you assure that your project is working Successfully.





































No comments:

Post a Comment

Hadoop Commands

HADOOP COMMANDS OS : Ubuntu Environment Author : Bottu Gurunadha Rao Created: 31-Jan-2022 Updated: 31-Jan-2022 Release  : 1.0.1 Purpose: To ...

Search This Blog