Building Web Applications in Django Coursera Quiz Answers

Get All Weeks Building Web Applications in Django Coursera Quiz Answers

Week 01: Building Web Applications in Django Coursera Quiz Answers

Quiz 1: Django Tutorial Part 2

Q1. These questions come from the Django project tutorial materials.

What is the default database backend for Django projects when they are first set up?

View
sqlite3

Q2. What file contains the list of INSTALLED_APPS in a Django project?

View
settings.py

Q3. What does the “python manage.py migrate” command do?

View
Builds/updates the database structure for the project

Q4. What is the purpose of the models.py file?

View
To define the shape of the data objects to be stored in a database

Q5. What does the “sqlmigrate” option accomplish in a Django application?

View
It lets you see the SQL that will run to effect a migration

Q6. What does the str method in a Django model accomplish?

View
It lets you specify how an instance of the model will be represented as a string

Q7. What is the difference between the Django shell and a normal interactive Python shell?

View
The Django shell loads all of the project objects before starting

Q8. What is the Django command to create a user/password for the admin user interface?

View
createsuperuser

Q9. What file in a Django application do you edit to make sure a model appears in the admin interface?

View
admin.py

Quiz 2: Model View Controller

Q1. Which of these might you find in the View of a Django MVC application?

View
1.HTML
2.Python

Q2. Which of these might you find in the Model of a Django MVC application?

View
1.SQL
2.Python

Q3. Which of these might you find in the Controller of a Django MVC application?

View
Python

Q4. Which of the following is typically the first task when handing an incoming HTTP request in web server code?

View
Retrieve any needed data for the View

Q5. Which of the following files does Django consult first when it receives an incoming HTTP Request?

View
urls.py

Q6. Which of the following files in a Django application most closely captures the notion of “View”?

View
views.py

Q7. Which file represents the “Controller” aspect of a Django application?

View
1.forms.py
2.views.py

Week 2: Building Web Applications in Django Coursera Quiz Answers

Quiz 1: Templates and Views

Q1. What does the built-in Django template tag “lorem” do?

View
Displays random “lorem ipsum” Latin text

Q2. What does the built-in Django template tag “spaceless” do?

View
Removes whitespace between HTML tags

Q3. What does the built-in Django template tag “url” do?

View
Returns an absolute path reference matching a given view and optional parameters

Q4. What built-in Django template filter capitalizes the first character of the value?

View
capfirst

Q5. What does the built-in Django template filter “length” do?

View
Returns the length of a list but not the length of a string

Q6. What does the built-in Django template filter “safe” do?

View
Marks a string as not requiring further HTML escaping prior to output

Q7. Looking at the Django built-in template and filter documentation, the author seems to have a pet named “Joel”. What kind of animal is their pet?

View
A bearded gecko

Q8. What does the Django built-in template tag forloop.counter represent in a Django template?

View
The current iteration of the loop (1-indexed)

Quiz 2: Tutorial 3

Q1. These questions come from the Django project tutorial materials.

When do you see a path with the following pattern in urls.py, path(‘/’, views. detail, name=’detail’),

where in the code does the question_id value parsed from the URL end up?

View
As an additional parameter to the detail() view

Q2. What kind of data is passed into a view in the ‘request’ object?

View
Information about the incoming HTTP request from the browser

Q3. Which of the following SQL commands will be run by the Question.objects.values() statement in a view function?

View
SELECT

Q4. How do you indicate that a particular question cannot be found in a detail view?

View
Raise an Http404 exception

Q5. How do you retrieve only the first five objects in a table using a Django model query?

View
Add [:5] to the end of the model query

Q6. In Django, why do we add an extra folder (i.e., namespace) our templates?

View
To make sure there is not a conflict with a template of the same name in a different application

Q7. What is the difference between a list view and detail view?

View
A list view shows multiple items and a detail view shows only one item

Q8. What is a “404” error?

View
It tells a browser that it did not get the page it was looking for

Q9. In Django, what is the default language used in HMTL template files?

View
DTL – Django Templating language

Q10. If the “get_object_or_404()” helper function finds the requested item, it returns the item. What happens if it cannot return the item?

View
It raises an Http404 exception

Q11. Why do we name space URL names using the “app_name” variable in the urls.py file?

View
In case we have multiple applications with the same named path

Week 3: Building Web Applications in Django Coursera Quiz Answers

Quiz 1: Object-Oriented Python

Q1. Which came first, the instance or the class?

View
class

Q2. In Object Oriented Programming, what is another name for the attributes of an object?

View
fields

Q3. Which of the following is NOT a good synonym for “class” in Python?

View
direction

Q4. What does this Python statement do if PartyAnimal is a class?

View
Use the PartyAnimal template to make a new object and assign it to zap
zap = PartyAnimal()

Q5. What is the syntax to look up the fullname attribute in an object stored in the variable colleen?

View
colleen.fullname

Q6. Which of the following statements are used to indicate that class A will inherit all the features of class B?

View
class A(B):

Q7. What is “self” typically used for in a Python method within a class?

View
To refer to the instance in which the method is being called

Q8. What does the Python dir() function show when we pass an object into it as a parameter?

View
It shows the methods and attributes of an object

Q9. Which of the following is rarely used in Object Oriented Programming?

View
Destructor

Quiz 2: Generic Views

Q1. In the class django.views.generic.list.ListView, which of the following methods is called earliest in the process?

View
get_queryset()

Q2. In the class django.views.generic.list.ListView, which of the following methods is called latest in the process?

View
render_to_response()

Q3. In the class django.views.generic.detail.DetailView, which of the following methods is called earliest in the process?

View
get_queryset()

Q4. In the class django.views.generic.detail.DetailView, which of the following methods is called latest in the process?

View
render_to_response()

Q5. By convention when using an app_name of “abc” and a model of “Dog”, if you use a View that extends django.views.generic.detail.DetailView, what is the file name that will be used for the template?

View
templates/abc/dog_detail.html

Q6. If you want to override the template name chosen by convention in a View that extends django.views.generic.detail.DetailView, what is the name of the class attribute variable that you use?

View
template_name

Q7. By convention when using an app_name of “abc” and a model of “Dog”, if you use a View that extends django.views.generic.list.ListView, what is the name of the context variable that will include all the Dog objects in the template when it is being rendered?

View
dog_list

Q8. For the following line in a views.py file

View
The class that is being created
class ArticleListView(ListView):

what is the best description of “ListView”?

Q9. For the following line in a views.py file

View
The class that is being created
class ArticleListView(ListView):

what is the best description of “ArticleListView”?

Q10. For the following line in a urls.py file

View
In the Django source
urlpatterns = [
path('', TemplateView.as_view(template_name='gview/main.html'))
where would you find the actual code for TemplateView?

Week 4: Building Web Applications in Django Coursera Quiz Answers

Quiz 1: Tutorial 4

Q1. These questions come from the Django project tutorial materials.

What is stored in the variable request.POST?

View
A dictionary-like object that lets you access submitted POST data

Q2. What does the django.urls.reverse() function do?

View
It constructs the path to a view using the name of a path entry in urls.py

Q3. What happens if you access a detail view like results() in Django tutorial 4 and provide a key that does not exist on the URL?

View
You get a 404

Q4. In the polls/templates/polls/detail.html file in Django tutorial 4, what happens if you leave out the csrf_token line in the form?

View
The POST data will be blocked by the server

Q5. In the polls/templates/polls/detail.html file in Django tutorial 4, which bit of code tells the view that will receive the POST data which question to associate this vote with?

View
url ‘polls:vote’ question.id

Q6. Which HTTP method is used when sending data to the server that will modify or update data?

View
POST

Q7. What does the Django template filter “pluralize” do?

View
It emits an ‘s’ if the value is > 1

Quiz 2: Forms and HTML

Q1. Which of the following HTTP methods adds form data to the URL after a question mark?

View
GET

Q2. Which of the following HTTP methods is recommended for sending data to the server that will modify a model?

View
POST

Q3. Which of the following Python types is most like the request.POST data in Django?

View
dictionary

Q4. How does the browser send form data to the server when sending a POST request?

View
Using the socket after the request headers have been sent

Q5. When using the password field type in HTML, the data is encrypted before it is sent to the server.

View
True

Q6. There is no way the end user can see the actual data stored in a password form field.

View
True

Q7. How do radio buttons in HTML associate with each other?

View
They use the same name parameter

Q8. What HTTP response code is sent to a browser when a missing or incorrect CSRF value is detected by Django?

View
403

Q9. What HTTP code is sent to the browser to redirect it to another page?

View
302

Q10. Why do we consider the POST-Redirect-GET pattern best practice?

View
To avoid triggering the browser double-post popup
Get All Course Quiz Answers of Django for Everybody’s Specialization

Web Application Technologies and Django Quiz Answers

Building Web Applications in Django Coursera Quiz Answers

Django Features and Libraries Coursera Quiz Answers

Using JavaScript, JQuery, and JSON in Django Coursera Quiz Answers

Team Networking Funda
Team Networking Funda

We are Team Networking Funda, a group of passionate authors and networking enthusiasts committed to sharing our expertise and experiences in networking and team building. With backgrounds in Data Science, Information Technology, Health, and Business Marketing, we bring diverse perspectives and insights to help you navigate the challenges and opportunities of professional networking and teamwork.

Leave a Reply

Your email address will not be published. Required fields are marked *