Top 100 Python Interview Questions You Must Prepare In 2019


Ans: Django MVT Pattern:  Figure



Download 163,96 Kb.
Pdf ko'rish
bet20/20
Sana02.06.2023
Hajmi163,96 Kb.
#948348
1   ...   12   13   14   15   16   17   18   19   20
Bog'liq
Top 100 Python Interview Questions

Ans: Django MVT Pattern:



Figure:  
Python Interview Questions – Django Architecture
The developer provides the Model, the view and the template then just maps it to a URL and Django does the magic to serve it to
the user.
Q77. Explain how you can set up the Database in Django.
Ans: You can use the command edit mysite/setting.py, it is a normal python module with module level representing Django
settings.
Django uses SQLite by default; it is easy for Django users as such it won’t require any other type of installation. In the case your
database choice is di erent that you have to the following keys in the DATABASE ‘default’ item to match your database
connection settings.
Engines: you can change the database by using ‘django.db.backends.sqlite3’ , ‘django.db.backeneds.mysql’,
‘django.db.backends.postgresql_psycopg2’, ‘django.db.backends.oracle’ and so on
Name: The name of your database. In the case if you are using SQLite as your database, in that case, database will be a le
on your computer, Name should be a full absolute path, including the le name of that le.
If you are not choosing SQLite as your database then settings like Password, Host, User, etc. must be added.
Django uses SQLite as a default database, it stores data as a single le in the lesystem. If you do have a database server—
PostgreSQL, MySQL, Oracle, MSSQL—and want to use it rather than SQLite, then use your database’s administration tools to
create a new database for your Django project. Either way, with your (empty) database in place, all that remains is to tell Django
how to use it. This is where your project’s settings.py le comes in.
We will add the following lines of code to the 
setting.py
le:
DATABASES = { 
'default': { 
'ENGINE' : 'django.db.backends.sqlite3', 
'NAME' : os.path.join(BASE_DIR, 'db.sqlite3'), 


Q78. Give an example how you can write a VIEW in Django?
Ans: This is how we can use write a view in Django:
from django.http import HttpResponse 
import datetime 
def Current_datetime(request): 
now = datetime.datetime.now() 
html = "It is now %s
Download 163,96 Kb.

Do'stlaringiz bilan baham:
1   ...   12   13   14   15   16   17   18   19   20




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish