JavaScript isn't enabled in your browser, so this file can't be opened. Enable and reload.
Django Part-I
Sign in to Google
to save your progress.
Learn more
* Indicates required question
What is the correct way to begin a class called "Rainbow" in Python?
*
1 point
Rainbow {}
export Rainbow:
class Rainbow:
def Rainbow:
Which skills do you need to maintain a set of Django templates?
*
1 point
template syntax
HTML and template syntax
Python, HTML, and template syntax
Python and template syntax
In which programming language is Django written?
*
1 point
C++
Java
Python
Ruby
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 point
django-admin startproject requirements.txt
python install -r requirements.txt
pip install -r requirements.txt
pip install Django
How do you determine at startup time if a piece of middleware should be used?
*
1 point
Raise MiddlewareNotUsed in the init function of your middleware.
Implement the not_used method in your middleware class.
List the middleware beneath an entry of django.middleware.IgnoredMiddleware.
Write code to remove the middleware from the settings in [app]/init.py.
How do you turn off Django’s automatic HTML escaping for part of a web page?
*
1 point
Place that section between paragraph tags containing the autoescape=off switch.
Wrap that section between { percentage mark autoescape off percentage mark} and {percentage mark endautoescape percentage mark} tags.
Wrap that section between {percentage mark autoescapeoff percentage mark} and {percentage mark endautoescapeoff percentage mark} tags.
You don't need to do anything—autoescaping is off by default.
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?
*
1 point
url(r'shows/int:season/int:episode/', views.episode_number)
path('shows/int:season/int:episode/', views.episode_number),
path('shows/int:season/int:episode', views.episode_number),
url(r'^show/(?P[0-9]+)/(?P[0-9]+)/$', views.episode_number),
What is the correct way to make a variable available to all of your templates?
*
1 point
Set a session variable.
Use a global variable.
Add a dictionary to the template context.
Use RequestContext.
Which is NOT a valid step in configuring your Django 2.x instance to serve up static files such as images or CSS?
*
1 point
In your urls file, add a pattern that includes the name of your static directory.
Create a directory named static inside your app directory.
Create a directory named after the app under the static directory, and place static files inside.
Use the template tag {percentage mark load static percentage mark}.
Every time a user is saved, their quiz_score needs to be recalculated. Where might be an ideal place to add this logic?
*
1 point
template
model
database
view
Django's class-based generic views provide which classes that implement common web development tasks?
*
1 point
concrete
thread-safe
abstract
dynamic
Which step would NOT help you troubleshoot the error "django-admin: command not found"?
*
1 point
Check that the bin folder inside your Django directory is on your system path.
Make sure you have activated the virtual environment you have set up containing Django.
Check that you have installed Django.
Make sure that you have created a Django project.
To cache your entire site for an application in Django, you add all except which of these settings?
*
1 point
django.middleware.common.CommonMiddleware
django.middleware.cache.UpdateCacheMiddleware
django.middleware.cache.FetchFromCacheMiddleware
django.middleware.cache.AcceleratedCacheMiddleware
What will this URL pattern match? url(r'^$', views.hello)
*
1 point
a string beginning with the letter Ra string beginning with the letter R
an empty string at the server root
a string containing ^ and $a string containing ^ and $
an empty string anywhere in the URLan empty string anywhere in the URL
You want to create a page that allows editing of two classes connected by a foreign key (e.g., a question and answer that reside in separate tables). What Django feature can you use?
*
1 point
actions
admin
mezcal
inlines
What is the typical order of an HTTP request/response cycle in Django?
*
1 point
URL > view > template
form > model > view
template > view > model
URL > template > view > model
Should you create a custom user model for new projects?
*
1 point
No. Using a custom user model could break the admin interface and some third-party apps.
Yes. It is easier to make changes once it goes into production.
No. Django's built-in models.User class has been tried and tested—no point in reinventing the wheel.
Yes, as there is no other option.
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 point
validate(); Model
group(); Model
validate(); Form
clean(); Field
Which best practice is NOT relevant to migrations?
*
1 point
To make sure that your migrations are up to date, you should run updatemigrations before running your tests.
You should back up your production database before running a migration.
Your migration code should be under source control.
If a project has a lot of data, you should test against a staging copy before running the migration on production.
Why are QuerySets considered "lazy"?
*
1 point
The results of a QuerySet are not ordered.
QuerySets do not create any database activity until they are evaluated.
QuerySets do not load objects into memory until they are needed.
Using QuerySets, you cannot execute more complex queries.
Submit
Page 1 of 1
Clear form
Forms
This content is neither created nor endorsed by Google.
Report Abuse
Terms of Service
Privacy Policy
Help and feedback
Contact form owner
Help Forms improve
Report