Exp 8 04
Exp 8 04
EXPERIMENT ASSESSMENT
Year: SE SEM: IV
Experiment No. 8
Roll Number: 04
Evaluation
Performance Indicator Max. Marks Marks Obtained
Performance 5
Understanding 5
Journal work and timely submission. 10
Total 20
Performance Indicator Exceed Expectations (EE) Meet Expectations (ME) Below Expectations (BE)
Performance 5 3 2
Understanding 5 3 2
Journal work and timely
10 8 4
submission.
Checked by
AIM: Creating web application using Django framework to demonstrate functionality of user
login and registration
THEORY:
Django is a high-level Python web framework that encourages rapid development and clean,
pragmatic design. 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.
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 : myworld.
Type the following in the command prompt, remember to navigate to where you want to
create your project
py-m venv myworld
This will set up a virtual environment, and create a folder named "myworld" with subfolders
and files, like this:
myworld
Include
Lib
Scripts
pyvenv.cfg
Then you have to activate the environment, by typing this command:
myworld\Scripts\activate.bat
Once the environment is activated, you will see this result in the command prompt:
(myworld) C:\Users\
Django is installed using pip, with this command:
(myworld) C:\Users\Your Name>py-m pip install Django
Once you have come up with a suitable name for your Django project, like mine:
my_tennis_club, navigate to where in the file system you want to store the code (in the virtual
Vidyavardhini’s College of Engineering & Technology
K.T. MARG, VASAI ROAD (WEST)
Department of Computer Science and Engineering(Data Science)
environment), I will navigate to the myworld folder, and run this command in the command
prompt:
django-admin startproject my_tennis_club
Django creates a my_tennis_club folder on my computer, with this content:
my_tennis_club
manage.py
my_tennis_club/
__init__.py
asgi.py
settings.py
urls.py
wsgi.py
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 /my_tennis_club 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.
An app is a web application that has a specific meaning in your project, like a home page, a
contact form, or a members database
Start by navigating to the selected location where you want to store the app, in my case the
my_tennis_club folder, and run the command below.
If the server is still running, and you are not able to write commands, press [CTRL]
[BREAK], or [CTRL] [C] to stop the server and you should be back in the virtual
environment.
py manage.py startapp members
Django views are Python functions that takes http requests and returns http response, like
HTML documents. A webpage that uses Django is full of views with different tasks and
missions. Views are usually put in a file called views.py located on your app's folder.
Find it and open it, and replace the content with this:
my_tennis_club/members/views.py:
from django.shortcuts import render
from django.http import HttpResponse
Vidyavardhini’s College of Engineering & Technology
K.T. MARG, VASAI ROAD (WEST)
Department of Computer Science and Engineering(Data Science)
def members(request):
return HttpResponse("Hello world!")
Create a file named urls.py in the same folder as the views.py file, and type this code in it:
my_tennis_club/members/urls.py:
from django.urls import path
from . import views
urlpatterns = [
path('', include('members.urls')), path('admin/', admin.site.urls), ]
If the server is not running, navigate to the /my_tennis_club folder and execute this command
in the command prompt:
py manage.py runserver
In the browser window, type 127.0.0.1:8000/members/ in the address bar.
Vidyavardhini’s College of Engineering & Technology
K.T. MARG, VASAI ROAD (WEST)
Department of Computer Science and Engineering(Data Science)
Screenshot:
Database snapshot:
Login page:
Vidyavardhini’s College of Engineering & Technology
K.T. MARG, VASAI ROAD (WEST)
Department of Computer Science and Engineering(Data Science)
Register page:
Conclusion: Identify other framework similar to django framework and describe the
advantages of django framework.
ANS :