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

Django

Uploaded by

Gokila Vaani
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Django

Uploaded by

Gokila Vaani
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Django

What Is Django?

• Django is full-stack, open source and written in Python.

• Python Django is a web framework that allows to quickly create


efficient web pages.

• It follows the Model-View-Template (MVT) architecture, making it


suitable for both small and large-scale web applications.
Features Of Django
• Model-View-Template (MVT) Architecture

• Object-Relational Mapping (ORM)

• Built-in Admin Panel

• User Authentication System

• URL Routing
Create Project and App

The file system you want to store the code (in the virtual environment)

django-admin startproject core


APP
• 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.

py manage.py startapp home


Run Django
Starting development server at http://127.0.0.1:8000/
Django MVT
• The MVT (Model View Template) is a software design pattern.It is a
collection of three important components Model View and Template.

1. Model is a table in your database.

2. Views are python functions that take http requests and return http
response, like html documents.

3. Templates provides a convenient way to generate dynamic html pages by


using its template system.
Example Code Using Forms
Forms are used for taking input from the user in some manner and using that information
for logical operations on databases. Creating Forms
Views
A form comes with 3 in-built methods
that can be used to render Django form
fields.
•{{ form.as_table }} will render them
as table cells wrapped in <tr> tags
•{{ form.as_p }} will render them
wrapped in <p> tags
•{{ form.as_ul }} will render them
wrapped in <li> tags
Templates :home.HTML

<form action = "" method = "post">

{% csrf_token %}

{{form }}

<input type="submit" value=Submit">

</form>
Models
ModelForm is a class that is used to directly convert a model into a Django
form.
OUTPUT
Thankyou

You might also like