0% found this document useful (0 votes)
16 views3 pages

Django Web Development Guide

Django is a fast and secure web development framework that enhances cost-effectiveness by reducing development time. To create a project in Django, one must set up a virtual environment, install Django, create a project and app, and run migrations. Additionally, Django provides commands for checking versions, managing translations, defining URL patterns, creating QuerySets, and loading data from fixture files.

Uploaded by

Ritu Kadiya
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

Django Web Development Guide

Django is a fast and secure web development framework that enhances cost-effectiveness by reducing development time. To create a project in Django, one must set up a virtual environment, install Django, create a project and app, and run migrations. Additionally, Django provides commands for checking versions, managing translations, defining URL patterns, creating QuerySets, and loading data from fixture files.

Uploaded by

Ritu Kadiya
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Module 5:(DB and Python Framework)

Que Why Django should be used for web-


1 development? Explain how you can create a
project in Django?
Ans:  Django is a fast and simple framework that
helps to save development time and
therefore increase the overall cost-
effectiveness of the project. Also, Django has
one of the best out-of-the-box security
systems out there. It helps developers avoid
common security issues that could otherwise
incur additional costs later.
- Some Step's to create a project in Django :
(1)create virtual env. ---> python -m venv
(2)pip install django - For Install Django
(3)django-admin startproject projectname
For Create a Django Project
(4)python [Link] startapp appname - For
Create a Django App
(5)python [Link] makemigrations - For
Create Database
(6)python [Link] migrate - for mgrate the
database
(7)python [Link] runserver - For Run the
Development Server
Que 2 How to check installed version of django?
Ans:  Open your command line or terminal and run
the following command : python -m django --
version
Que 3 Explain what does [Link] make
messages command is used for?
Ans:  The make_messages command scans your
Django project for text strings marked for
translation in your code and creates or
updates message files for different
languages.
 These message files contain the original text
strings and placeholders, and they serve as
templates for translators to provide

RITU KADIYA
Module 5:(DB and Python Framework)
translations.
Que 4 What is Django URLs?make program to create
django urls
Ans:  In Django, URLs are patterns used to map
URLs to views within a web application. The
URL patterns are defined in the [Link]
module of each Django app, and they
determine which view function or class-based
view should be called for a given URL.
 [Link]:
from [Link] import path
from . import views

urlpatterns = [
path('', [Link], name='index'),
path('about/', [Link], name='about'),
path('contact/', [Link], name='contact'),
]
Que 5 What is a QuerySet ? Write program to
create a new Post object in database.
Ans:  QuerySet : QuerySet is a collection of
database queries that can be used to
retrieve data from a database. It's a high-
level API provided by Django for interacting
with databases.
 [Link]:
from [Link] import models

# Create your models here.


class User([Link]):
fname=[Link](max_length=100)
lname=[Link](max_length=100)
email=[Link]()
mobile=[Link]()
address=[Link]()
password=[Link](max_length=100)
profile_picture=[Link](upload_to="profile_picture/",default="")
usertype=[Link](max_length=100,default="user")

def __str__(self):
return [Link]+" "+[Link]

Que 6 Mention what command line can be used to load


data into Django?
Ans:  Django provides a management command

RITU KADIYA
Module 5:(DB and Python Framework)
called 'load data' that allows you to load data
into your Django application from fixture
files. Fixture files are serialized
representations of Django models, typically
in JSON, YAML, or XML format.

RITU KADIYA

You might also like