Django

To cache your entire site for an application in Django, you add all except which of these settings?

1.

django.middleware.common.CommonMiddleware

2.

django.middleware.cache.UpdateCacheMiddleware

3.

django.middleware.cache.FetchFromCacheMiddleware

4.

django.middleware.cache.AcceleratedCacheMiddleware

Q 1 / 65

Django

In which programming language is Django written?

1.

C++

2.

Java

3.

Python

4.

Ruby

Q 2 / 65

Django

To automatically provide a value for a field, or to do validation that requires access to more than a single field, you should override the `___` method in the `___` class.

1.

validate(); Model

2.

group(); Model

3.

validate(); Form

4.

clean(); Field

Q 3 / 65

Django

A client wants their site to be able to load "Rick & Morty" episodes by number or by title—e.g., shows/3/3 or shows/picklerick. Which URL pattern do you recommend?

url(r'shows/<int:season>/<int:episode>/', views.episode_number), url(r'shows/<slug:episode_name>/', views.episode_name) path('shows/<int:season>/<int:episode>/', views.episode_number), path(r'shows/<slug:episode_name>/', views.episode_name) path('shows/<int:season>/<int:episode>', views.episode_number), path(r'shows/<slug:episode_name>/', views.episode_number) url(r'^show/(?P<season>[0-9]+)/(?P<episode>[0-9]+)/$', views.episode_number), url(r'^show/(?P<episode_name>[w-]+)/', views.episode_name

1.

url(r'shows/<int:season>/<int:episode>/', views.episode_number), url(r'shows/<slug:episode_name>/', views.episode_name)

2.

path('shows/<int:season>/<int:episode>/', views.episode_number), path(r'shows/<slug:episode_name>/', views.episode_name)

3.

path('shows/<int:season>/<int:episode>', views.episode_number), path(r'shows/<slug:episode_name>/', views.episode_number)

4.

url(r'^show/(?P<season>[0-9]+)/(?P<episode>[0-9]+)/$', views.episode_number), url(r'^show/(?P<episode_name>[w-]+)/', views.episode_name

Q 4 / 65

Django

How do you determine at startup time if a piece of middleware should be used?

1.

Raise MiddlewareNotUsed in the **init** function of your middleware.

2.

Implement the not_used method in your middleware class.

3.

List the middleware beneath an entry of django.middleware.IgnoredMiddleware.

4.

Write code to remove the middleware from the settings in [app]/**init**.py.

Q 5 / 65

Django

How do you turn off Django’s automatic HTML escaping for part of a web page?

1.

Place that section between paragraph tags containing the autoescape=off switch.

2.

Wrap that section between { percentage mark autoescape off percentage mark} and {percentage mark endautoescape percentage mark} tags.

3.

Wrap that section between {percentage mark autoescapeoff percentage mark} and {percentage mark endautoescapeoff percentage mark} tags.

4.

You don't need to do anything—autoescaping is off by default.

Q 6 / 65

Django

Which step would NOT help you troubleshoot the error "django-admin: command not found"?

1.

Check that the bin folder inside your Django directory is on your system path.

2.

Make sure you have activated the virtual environment you have set up containing Django.

3.

Check that you have installed Django.

4.

Make sure that you have created a Django project.

Q 7 / 65

Django

Every time a user is saved, their quiz_score needs to be recalculated. Where might be an ideal place to add this logic?

1.

template

2.

model

3.

database

4.

view

Q 8 / 65

Django

What is the correct way to begin a class called "Rainbow" in Python?

1.

Rainbow {}

2.

export Rainbow:

3.

class Rainbow:

4.

def Rainbow:

Q 9 / 65

Django

You have inherited a Django project and need to get it running locally. It comes with a requirements.txt file containing all its dependencies. Which command should you use?

1.

django-admin startproject requirements.txt

2.

python install -r requirements.txt

3.

pip install -r requirements.txt

4.

pip install Django

Q 10 / 65

Django

Which best practice is NOT relevant to migrations?

1.

To make sure that your migrations are up to date, you should run updatemigrations before running your tests.

2.

You should back up your production database before running a migration.

3.

Your migration code should be under source control.

4.

If a project has a lot of data, you should test against a staging copy before running the migration on production.

Q 11 / 65

Django

What will this URL pattern match? url(r'^$', views.hello)

1.

a string beginning with the letter Ra string beginning with the letter R

2.

an empty string at the server root

3.

a string containing ^ and $a string containing ^ and $

4.

an empty string anywhere in the URLan empty string anywhere in the URL

Q 12 / 65

Django

What is the typical order of an HTTP request/response cycle in Django?

1.

URL > view > template

2.

form > model > view

3.

template > view > model

4.

URL > template > view > model

Q 13 / 65

Django

Django's class-based generic views provide which classes that implement common web development tasks?

1.

concrete

2.

thread-safe

3.

abstract

4.

dynamic

Q 14 / 65

Django

Which skills do you need to maintain a set of Django templates?

1.

template syntax

2.

HTML and template syntax

3.

Python, HTML, and template syntax

4.

Python and template syntax

Q 15 / 65

Django

undefined

class Star(models.Model): name = models.CharField(max_length=100) class Constellation(models.Model): stars = models.ManyToManyField(Star) class Star(models.Model): constellation = models.ForeignKey(Constellation, on_delete=models.CASCADE) class Constellation(models.Model): stars = models.ForeignKey(Star, on_delete=models.CASCADE) class Star(models.Model): name = models.CharField(max_length=100) class Constellation(models.Model): stars = models.OneToManyField(Star) class Star(models.Model): constellation = models.ManyToManyField(Constellation) class Constellation(models.Model): name = models.CharField(max_length=100)

1.

class Star(models.Model): name = models.CharField(max_length=100) class Constellation(models.Model): stars = models.ManyToManyField(Star)

2.

class Star(models.Model): constellation = models.ForeignKey(Constellation, on_delete=models.CASCADE) class Constellation(models.Model): stars = models.ForeignKey(Star, on_delete=models.CASCADE)

3.

class Star(models.Model): name = models.CharField(max_length=100) class Constellation(models.Model): stars = models.OneToManyField(Star)

4.

class Star(models.Model): constellation = models.ManyToManyField(Constellation) class Constellation(models.Model): name = models.CharField(max_length=100)

Q 16 / 65

Django

undefined

1.

In your urls file, add a pattern that includes the name of your static directory.

2.

Create a directory named static inside your app directory.

3.

Create a directory named after the app under the static directory, and place static files inside.

4.

Use the template tag {percentage mark load static percentage mark}.

Q 17 / 65

Django

undefined

1.

Set a session variable.

2.

Use a global variable.

3.

Add a dictionary to the template context.

4.

Use RequestContext.

Q 18 / 65

Django

undefined

1.

No. Using a custom user model could break the admin interface and some third-party apps.

2.

Yes. It is easier to make changes once it goes into production.

3.

No. Django's built-in models.User class has been tried and tested—no point in reinventing the wheel.

4.

Yes, as there is no other option.

Q 19 / 65

Django

undefined

1.

actions

2.

admin

3.

mezcal

4.

inlines

Q 20 / 65

Django

undefined

1.

The results of a QuerySet are not ordered.

2.

QuerySets do not create any database activity until they are evaluated.

3.

QuerySets do not load objects into memory until they are needed.

4.

Using QuerySets, you cannot execute more complex queries.

Q 21 / 65

Django

undefined

1.

Switch to using POST instead of GET as the request method.

2.

Make sure the input field in your form is also named "search_term".

3.

Use MultiValueDict's GET method instead of hitting the dictionary directly like this: request.GET.get('search_term', '').

4.

Check if the search_term parameter is present in the request before attempting to access it.

Q 22 / 65

Django

undefined

1.

show_fields()

2.

as_p()

3.

as_table()

4.

fields()

Q 23 / 65

Django

undefined

1.

Fork the Django repository GitHub.

2.

Submit a pull request.

3.

all of these answers.

4.

Run Django's test suite.

Q 24 / 65

Django

undefined

1.

django.utils.default_settings.py

2.

django.utils.global_settings.py

3.

django.conf.default_settings.py

4.

django.conf.global_settings.py

Q 25 / 65

Django

undefined

1.

numFingers

2.

number-of-Fingers

3.

number_of_fingers

4.

finger_num

Q 26 / 65

Django

undefined

1.

Manually merge your migration files to reduce the number

2.

Don't worry about the number

3.

Try to minimize the number of migrations

4.

Use squashmigrations to reduce the number

Q 27 / 65

Django

undefined

1.

perform db operations without fetching a model object

2.

define db transaction isolation levels

3.

use aggregate functions more easily

4.

build reusable QuerySets

Q 28 / 65

Django

undefined

1.

SmallIntegerField

2.

NegativeIntegerField

3.

BigAutoField

4.

PositiveIntegerField

Q 29 / 65

Django

undefined

1.

print (django.version)

2.

import django django.getVersion()

3.

import django django.get_version()

4.

python -c django --version

Q 30 / 65

Django

undefined

1.

READ; WRITE

2.

GET; POST

3.

POST; GET

4.

GET; PATCH

Q 31 / 65

Django

undefined

1.

when efficiency is important

2.

when you want the data to be cached

3.

when you want to use your browser to help with debugging

4.

when the data in the form may be sensitive

Q 32 / 65

Django

undefined

1.

if your single installation powers more than one site

2.

if you need to serve static as well as dynamic content

3.

if you want your app have a fully qualified domain name

4.

if you are expecting more than 10.000 users

Q 33 / 65

Django

undefined

`title=models.charfield(max_length=100, validators=[validate_spelling])`

1.

inizialized array called validators

2.

a validators file containing a function called validate_spelling imported at the top of model

3.

a validators file containing a function called validate imported at the top of model

4.

spelling package imported at the top of model

Q 34 / 65

Django

undefined

1.

require_safe()

2.

require_put()

3.

require_post()

4.

require_get()

Q 35 / 65

Django

undefined

class Author (models.model): book=models.foreignkey(Book,on_delete=models.cascade) class Book(models.model): name=models.charfield(max_length=100) python class Author (models.model): name=models.charfield(max_length=100) class Book(models.model): author=models.foreignkey(Author,on_delete=models.cascade) class Author (models.model): name=models.charfield(max_length=100) class Book(models.model): author=models.foreignkey(Author) class Author (models.model): name=models.charfield(max_length=100) class Book(models.model): author=models.foreignkey(Author,on_delete=models.cascade) class Author (models.model): name=models.charfield(max_length=100) class Book(models.model): author=Author.name

1.

class Author (models.model): book=models.foreignkey(Book,on_delete=models.cascade) class Book(models.model): name=models.charfield(max_length=100)

2.

python class Author (models.model): name=models.charfield(max_length=100) class Book(models.model): author=models.foreignkey(Author,on_delete=models.cascade)

3.

class Author (models.model): name=models.charfield(max_length=100) class Book(models.model): author=models.foreignkey(Author)

4.

class Author (models.model): name=models.charfield(max_length=100) class Book(models.model): author=models.foreignkey(Author,on_delete=models.cascade)

5.

class Author (models.model): name=models.charfield(max_length=100) class Book(models.model): author=Author.name

Q 36 / 65

Django

undefined

1.

validator

2.

deodorizer

3.

mediator

4.

regular expression

Q 37 / 65

Django

undefined

1.

rest_framework.permissions.IsAdminUser

2.

rest_framework.permissions.IsAuthenticated

3.

rest_framework.permissions.IsAuthorized

4.

rest_framework.permissions.IsRegistered

Q 38 / 65

Django

undefined

1.

makemigration

2.

update_db

3.

applymigration

4.

migrate

Q 39 / 65

Django

undefined

1.

objectwriters

2.

serializers

3.

picklers

4.

viewsets

Q 40 / 65

Django

undefined

{ percentage if spark >= 50 percentage } Lots of spark {percentage elif spark == 42 percentage}

1.

{ percentage else percentage}

2.

{percentage endif percentage}

3.

Nothing needed

4.

{percentage end percentage}

Q 41 / 65

Django

undefined

from rest_framework import serializers from .models import Planet class PlanetSerializer(serializers.ModelSerializer): class Meta: model=Planet fields=('name','position', 'mass', 'rings') from rest_framework import serializers from .models import Planet class PlanetSerializer(): class Meta: fields=('name','position', 'mass', 'rings') model=Planet from django.db import serializers from .models import Planet class PlanetSerializer(serializers.ModelSerializer): fields=('name','position', 'mass', 'rings') model=Sandwich from django.db import serializers from .models import Planet class PlanetSerializer(serializers.ModelSerializer): class Meta: fields=('name') model=Planet

1.

class PlanetSerializer(serializers.ModelSerializer): class Meta: model=Planet fields=('name','position', 'mass', 'rings')

2.

from rest_framework import serializers from .models import Planet class PlanetSerializer(): class Meta: fields=('name','position', 'mass', 'rings') model=Planet

3.

from django.db import serializers from .models import Planet class PlanetSerializer(serializers.ModelSerializer): fields=('name','position', 'mass', 'rings') model=Sandwich

4.

from django.db import serializers from .models import Planet class PlanetSerializer(serializers.ModelSerializer): class Meta: fields=('name') model=Planet

Q 42 / 65

Django

undefined

1.

ModelSerializer

2.

Model

3.

DataSerializer

4.

ModelToSerializer

Q 43 / 65

Django

undefined

1.

django-admin setup

2.

django-admin runserver

3.

python manage.py createuser

4.

python manage.py createsuperuser

Q 44 / 65

Django

undefined

1.

you should set up a new virtualenv for each Django project

2.

They should not be used

3.

Use the same venv for all your Django work

4.

Use a new venv for each Django app

Q 45 / 65

Django

undefined

1.

migrate.py

2.

wsgi.py

3.

manage.py

4.

runserver

Q 46 / 65

Django

undefined

1.

models

2.

controllers

3.

programmers

4.

clients

Q 47 / 65

Django

undefined

1.

Loose Coupling

2.

Less Code

3.

Fast Development

4.

Implicit over explicit

Q 48 / 65

Django

undefined

{{"live long and prosper"|truncate:3}}

1.

live long and ...

2.

live long and

3.

a compilation error

4.

liv

Q 49 / 65

Django

undefined

1 sandwiches = Sandwich.objects.filter(is_vegan=True) 2 for sandwich in sandwiches: 3 print(sandwich.name + " - " + sandwich.spice_level)

1.

line 1

2.

It depends on how many results return by query.

3.

It depends on cache.

4.

line 2

Q 50 / 65

Django

undefined

1.

an NGINX web server

2.

a NoSQL database

3.

a larger hard drive

4.

CORS middleware

Q 51 / 65

Django

undefined

1.

an HTTP request

2.

a JSON object

3.

a query

4.

a serializer

Q 52 / 65

Django

undefined

1.

Run the `migrate` command with `--exclude=[model_name]`.

2.

Move the model definition from `models.py` into its own file.

3.

Set `managed=False` inside the model.

4.

Don't run the `migrate` command.

Q 53 / 65

Django

undefined

1.

has_changed()

2.

its_changed()

3.

has_updated()

4.

None of This

Q 54 / 65

Django

undefined

1.

a server

2.

an interface specification

3.

a Python module

4.

a framework

Q 55 / 65

Django

undefined

1.

DetailView

2.

TittleView

3.

SongView

4.

ListView

Q 56 / 65

Django

undefined

1.

There's less chance of introducing bugs since SQLite already works out the box

2.

It's fine, you just need to keep both instances synchronized

3.

It's a bad idea and could lead to issues down the road

4.

It's the most efficient way to build a project

Q 57 / 65

Django

undefined

1.

to perform database queries

2.

to set up a database for testing

3.

to modify the initial QuerySet that the Manager returns

4.

to filter the results that a database query returns

Q 58 / 65

Django

undefined

1.

models

2.

views

3.

forms

4.

serializers

Q 59 / 65

Django

undefined

shell % if sparles >= 50 % Lots of sparkles! % elif sparkles == 42 % The answer to life, the universe, and everything!

1.

`% endif %`

2.

Nothing else is needed.

3.

`% end%`

4.

`% else %`

Q 60 / 65

Django

undefined

1.

python install -r requirements.txt

2.

django-admin startproject requirements.txt

3.

pip install Django

4.

pip install -r requirements.txt

Q 61 / 65

Django

undefined

1.

when the data in the form may be sensitive

2.

when you want the data to be cached

3.

when you want to use your browser to help with debugging

4.

when efficiency is important

Q 62 / 65

Django

undefined

1.

mediator

2.

validator

3.

regular expression

4.

deodorizer

Q 63 / 65

Django

undefined

1.

request.META; FileField

2.

request.FILES; BLOBField

3.

request.FILES; FileField

4.

request.META.Files; CLOBField

Q 64 / 65

Django

undefined

1.

pickle

2.

struct

3.

marshal

4.

serialize

Q 65 / 65