Book Appointment Now
Building Web Applications in Django Coursera Quiz Answers
Get All Weeks Building Web Applications in Django Coursera Quiz Answers
Table of Contents
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?
[expand title=View Answer] sqlite3[/expand]
Q2. What file contains the list of INSTALLED_APPS in a Django project?
[expand title=View Answer] settings.py[/expand]
Q3. What does the “python manage.py migrate” command do?
[expand title=View Answer] Builds/updates the database structure for the project [/expand]
Q4. What is the purpose of the models.py file?
[expand title=View Answer] To define the shape of the data objects to be stored in a database[/expand]
Q5. What does the “sqlmigrate” option accomplish in a Django application?
[expand title=View Answer]It lets you see the SQL that will run to effect a migration [/expand]
Q6. What does the str method in a Django model accomplish?
[expand title=View Answer] It lets you specify how an instance of the model will be represented as a string [/expand]
Q7. What is the difference between the Django shell and a normal interactive Python shell?
[expand title=View Answer] The Django shell loads all of the project objects before starting [/expand]
Q8. What is the Django command to create a user/password for the admin user interface?
[expand title=View Answer] createsuperuser [/expand]
Q9. What file in a Django application do you edit to make sure a model appears in the admin interface?
[expand title=View Answer]admin.py [/expand]
Quiz 2: Model View Controller
Q1. Which of these might you find in the View of a Django MVC application?
[expand title=View Answer]
1.HTML
2.Python
[/expand]
Q2. Which of these might you find in the Model of a Django MVC application?
[expand title=View Answer]
1.SQL
2.Python
[/expand]
Q3. Which of these might you find in the Controller of a Django MVC application?
[expand title=View Answer] Python[/expand]
Q4. Which of the following is typically the first task when handing an incoming HTTP request in web server code?
[expand title=View Answer]Retrieve any needed data for the View[/expand]
Q5. Which of the following files does Django consult first when it receives an incoming HTTP Request?
[expand title=View Answer]urls.py [/expand]
Q6. Which of the following files in a Django application most closely captures the notion of “View”?
[expand title=View Answer] views.py [/expand]
Q7. Which file represents the “Controller” aspect of a Django application?
[expand title=View Answer]
1.forms.py
2.views.py
[/expand]
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?
[expand title=View Answer]Displays random “lorem ipsum” Latin text [/expand]
Q2. What does the built-in Django template tag “spaceless” do?
[expand title=View Answer] Removes whitespace between HTML tags [/expand]
Q3. What does the built-in Django template tag “url” do?
[expand title=View Answer] Returns an absolute path reference matching a given view and optional parameters[/expand]
Q4. What built-in Django template filter capitalizes the first character of the value?
[expand title=View Answer] capfirst [/expand]
Q5. What does the built-in Django template filter “length” do?
[expand title=View Answer] Returns the length of a list but not the length of a string [/expand]
Q6. What does the built-in Django template filter “safe” do?
[expand title=View Answer] Marks a string as not requiring further HTML escaping prior to output [/expand]
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?
[expand title=View Answer] A bearded gecko [/expand]
Q8. What does the Django built-in template tag forloop.counter represent in a Django template?
[expand title=View Answer] The current iteration of the loop (1-indexed) [/expand]
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?
[expand title=View Answer] As an additional parameter to the detail() view [/expand]
Q2. What kind of data is passed into a view in the ‘request’ object?
[expand title=View Answer]Information about the incoming HTTP request from the browser[/expand]
Q3. Which of the following SQL commands will be run by the Question.objects.values() statement in a view function?
[expand title=View Answer] SELECT[/expand]
Q4. How do you indicate that a particular question cannot be found in a detail view?
[expand title=View Answer] Raise an Http404 exception[/expand]
Q5. How do you retrieve only the first five objects in a table using a Django model query?
[expand title=View Answer] Add [:5] to the end of the model query [/expand]
Q6. In Django, why do we add an extra folder (i.e., namespace) our templates?
[expand title=View Answer] To make sure there is not a conflict with a template of the same name in a different application [/expand]
Q7. What is the difference between a list view and detail view?
[expand title=View Answer] A list view shows multiple items and a detail view shows only one item [/expand]
Q8. What is a “404” error?
[expand title=View Answer] It tells a browser that it did not get the page it was looking for [/expand]
Q9. In Django, what is the default language used in HMTL template files?
[expand title=View Answer] DTL – Django Templating language [/expand]
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?
[expand title=View Answer]It raises an Http404 exception [/expand]
Q11. Why do we name space URL names using the “app_name” variable in the urls.py file?
[expand title=View Answer]In case we have multiple applications with the same named path[/expand]
Week 3: Building Web Applications in Django Coursera Quiz Answers
Quiz 1: Object-Oriented Python
Q1. Which came first, the instance or the class?
[expand title=View Answer]class [/expand]
Q2. In Object Oriented Programming, what is another name for the attributes of an object?
[expand title=View Answer] fields [/expand]
Q3. Which of the following is NOT a good synonym for “class” in Python?
[expand title=View Answer] direction [/expand]
Q4. What does this Python statement do if PartyAnimal is a class?
[expand title=View Answer] Use the PartyAnimal template to make a new object and assign it to zap [/expand]
zap = PartyAnimal()
Q5. What is the syntax to look up the fullname attribute in an object stored in the variable colleen?
[expand title=View Answer] colleen.fullname [/expand]
Q6. Which of the following statements are used to indicate that class A will inherit all the features of class B?
[expand title=View Answer] class A(B): [/expand]
Q7. What is “self” typically used for in a Python method within a class?
[expand title=View Answer] To refer to the instance in which the method is being called [/expand]
Q8. What does the Python dir() function show when we pass an object into it as a parameter?
[expand title=View Answer] It shows the methods and attributes of an object [/expand]
Q9. Which of the following is rarely used in Object Oriented Programming?
[expand title=View Answer] Destructor [/expand]
Quiz 2: Generic Views
Q1. In the class django.views.generic.list.ListView, which of the following methods is called earliest in the process?
[expand title=View Answer]get_queryset()[/expand]
Q2. In the class django.views.generic.list.ListView, which of the following methods is called latest in the process?
[expand title=View Answer] render_to_response() [/expand]
Q3. In the class django.views.generic.detail.DetailView, which of the following methods is called earliest in the process?
[expand title=View Answer] get_queryset() [/expand]
Q4. In the class django.views.generic.detail.DetailView, which of the following methods is called latest in the process?
[expand title=View Answer] render_to_response()[/expand]
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?
[expand title=View Answer]templates/abc/dog_detail.html [/expand]
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?
[expand title=View Answer]template_name[/expand]
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?
[expand title=View Answer] dog_list [/expand]
Q8. For the following line in a views.py file
[expand title=View Answer] The class that is being created [/expand]
class ArticleListView(ListView):
what is the best description of “ListView”?
Q9. For the following line in a views.py file
[expand title=View Answer] The class that is being created [/expand]
class ArticleListView(ListView):
what is the best description of “ArticleListView”?
Q10. For the following line in a urls.py file
[expand title=View Answer] In the Django source [/expand]
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?
[expand title=View Answer] A dictionary-like object that lets you access submitted POST data [/expand]
Q2. What does the django.urls.reverse() function do?
[expand title=View Answer] It constructs the path to a view using the name of a path entry in urls.py[/expand]
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?
[expand title=View Answer] You get a 404 [/expand]
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?
[expand title=View Answer] The POST data will be blocked by the server [/expand]
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?
[expand title=View Answer] url ‘polls:vote’ question.id[/expand]
Q6. Which HTTP method is used when sending data to the server that will modify or update data?
[expand title=View Answer] POST [/expand]
Q7. What does the Django template filter “pluralize” do?
[expand title=View Answer] It emits an ‘s’ if the value is > 1 [/expand]
Quiz 2: Forms and HTML
Q1. Which of the following HTTP methods adds form data to the URL after a question mark?
[expand title=View Answer] GET [/expand]
Q2. Which of the following HTTP methods is recommended for sending data to the server that will modify a model?
[expand title=View Answer] POST [/expand]
Q3. Which of the following Python types is most like the request.POST data in Django?
[expand title=View Answer] dictionary [/expand]
Q4. How does the browser send form data to the server when sending a POST request?
[expand title=View Answer]Using the socket after the request headers have been sent [/expand]
Q5. When using the password field type in HTML, the data is encrypted before it is sent to the server.
[expand title=View Answer] True [/expand]
Q6. There is no way the end user can see the actual data stored in a password form field.
[expand title=View Answer] True [/expand]
Q7. How do radio buttons in HTML associate with each other?
[expand title=View Answer] They use the same name parameter [/expand]
Q8. What HTTP response code is sent to a browser when a missing or incorrect CSRF value is detected by Django?
[expand title=View Answer] 403 [/expand]
Q9. What HTTP code is sent to the browser to redirect it to another page?
[expand title=View Answer] 302[/expand]
Q10. Why do we consider the POST-Redirect-GET pattern best practice?
[expand title=View Answer] To avoid triggering the browser double-post popup[/expand]
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