You are here

Starting Django

Table of Contents

Checking if Django is installed and working:

Type the following on the command prompt to check whether Django is installed or not

C:\Users\ECE>django-admin

C:\Users\ECE>‘django-admin’ is not recognized as an internal or external command, operable program or batch file.

It simply is an indication that Django is not installed on your systems.

So first of all create a python virtual environment so that you can install Django and start working on the Django environment.

Steps for creating virtual environment

Example:

    1. Go to the Project Folder:- E:\project\webAppProjects
    1. Set virtualEnv  as              :     E:\project\webAppProjects>python -m venv venv
    2. Activate environment    : E:\project\webAppProjects>venv\Scripts\activate

Install Django 

Then install Django in that environment

(venv) E:\project\webAppProjects\webProject1>cd \

 (venv) E:\>pip install django

 Now you are ready to start Django for creating web applications

Working with Django:- here is the example of starting the project

  • create a project directory
  • run Django-admin startproject <projectName>

(venv) E:\project\webAppProjects>django-admin startproject webProject1

Working with Django Server:

  • Change to project directory: (venv) E:\project\webAppProjects>cd  webProject1
  • runserver: (venv) E:\project\webAppProjects/webProject1/> python manage.py runserver

following messages will appear on scree

Watching for file changes with StatReloader

Performing system checks…

System check identified no issues (0 silenced).

December 23, 2021 – 12:09:28

Django version 4.0, using settings ‘webProject1.settings’

Starting development server at http://127.0.0.1:8000/

Quit the server with CTRL-BREAK.

  • Copy the server url http://127.0.0.1:8000/ and paste in the address bar of the web browser. You will get the following django screen
Figure- django server page

 

 

Leave a Reply

Top
error: Content is protected !!