Q.1 Select the incorrect statement: Migration Operations ________.
A. records history of model changes
B. runs through models without touching database
C. migrations aren’t automatically done based on history of model changes
D. helps to load models to memory
Ans : migrations aren’t automatically done based on history of model changes
Q.2 How to make a migration run outside transaction in a DDL based transaction?
A. database files
B. migration files
C. database objects
D. text files
Ans : migration files
Q.3 How to make a migration run outside transaction in a DDL based transaction?
A. class Migration(migrations.Migration):
atomic = False
B. class Migration(migrations.Migration):
atomic = True
C. class Migration(migrations):
atomic = False
D. class Migration(migrations):
atomic = True
Ans : class Migration(migrations.Migration):
atomic = False
Q.4 Select the incorrect statement: Database Transaction ________.
A. is started by enabling autocommit using set_autocommit()
B. use commit() to apply the changes
C. is an atomic set of database queries which applies either all or no changes to the data
D. use rollback() to cancel the changes
Ans : is started by enabling autocommit using set_autocommit()
Q.5 Schema Migrations-run custom SQL using RunSQL or python code blocks using RunPython.
A. True
B. False
Ans : False
Q.6 The integrity of Django ORM operations involving multiple queries can be achieved through savepoints.
A. True
B. False
Ans : True
Q.7 What exception is raised, if the primary key is excluded from a Raw query?
A. InvalidField exception
B. InvalidAttribute exception
C. InvalidQuery exception
D. InvalidObject exception
Ans : InvalidQuery exception
Q.8 Select the incorrect statement: A database Router uses the method ________.
A. allow_migrate(db, app_label, model_name=None, **hints)
B. db_for_delete(model, **hints)
C. allow_relation(obj1, obj2, **hints)
D. db_for_write(model, **hints)
Ans : db_for_delete(model, **hints)
Q.9 What represents the logic layer of the program?
A. VIEWS
B. TEMPLATES
C. MODELS
D. CONTROLLERS
Ans : TEMPLATES
Q.10 Name the incorrect field option.
A. blank
B. null
C. choices
D. None of the options
Ans : blank
Q.11 Which is not an aggregation function?
A. variance
B. sum
C. filter
D. range
Ans : filter
Q.12 Identify the incorrect option: Method that does not return a new queryset.
A. difference()
B. exists()
C. first()
D. delete()
Ans : difference()
Q.13 Django helps to tackle ________.
A. Cross-site scripting
B. cross-site request forgery and clickjacking
C. SQL injection
D. All the options
Ans : All the options
Q.14 What do you call a migration that creates the first version of the app’s tables?
A. start migration
B. default migration
C. initial migration
D. first migration
Ans : initial migration
Q.15 Migrations usually Create the required scripts to change the structure by updating the code and changing your models.
A. True
B. False
Ans : True
Q.16 filter(**kwargs) – Returns QuerySet containing objects that do not match the given lookup parameters.
A. True
B. False
Ans : True
Q.17 Manager.raw() supports indexing.
A. True
B. False
Ans : True
Q.18 Connection and cursor mostly implement the standard Python DB-API.
A. True
B. False
Ans : True
Q.19 Identify the incorrect field lookup option.
A. regex
B. exact
C. lte
D. month
Ans : regex
Q.20 The ‘OR’ condition in queryset is possible because of using _____.
A. F() object
B. Q object AND F object
C. Q() object
D. None of the options
Ans : Q object AND F object
Q.21 Identify the incorrect option: Method that returns a new queryset.
A. earliest()
B. union()
C. raw()
D. none()
Ans : none()
Q.22 What is the act of reducing a set of migrations to one or few?
A. optimize
B. Squashing
C. reduce
D. None of the options
Ans : Squashing
Q.23 Which is not a python ORM implementation?
A. Storm
B. SQLAlchemy
C. PonyORM
D. hibernate
Ans : SQLAlchemy
Q.24 Which applies the changes till savepoint to the transaction and releases the SID?
A. savepoint_commit(sid, using=None)
B. savepoint_rollback(sid, using=None)
C. savepoint(using=None)
D. None of the options
Ans : savepoint_rollback(sid, using=None)
Q.25 Name the comparison and conversion database functions.
A. Least
B. Greatest
C. Cast
D. Coalesce
Ans : Cast
Q.26 To limit a queryset result to return objects from 4th through 8th object, use ________.
A. Mymodel.objects.all()[4:8]
B. Mymodel.objects.all()[:8]
C. Mymodel.objects.all()[3:8]
D. Mymodel.objects.all()[4:]
Ans : Mymodel.objects.all()[3:8]