Building Web Applications in Django | Week 4

Course Name: Django for Everybody

Sub-course: Building Web Applications in Django

Course Link: Django for Everybody

Sub-course Link: Building Web Applications in Django

These are Building Web Applications in Django Week 4 answers Coursera Quiz


Tutorial 4

Q1. These questions come from the Django project tutorial materials.
What is stored in the variable request.POST?

  • The code that runs after a view method is complete
  • The next page to redirect the browser to after the processing is complete
  • The name of the model to store an extra copy of the incoming data
  • A dictionary-like object that lets you access submitted POST data

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


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

  • It sends the POST data back to the browser if there is an error
  • It sends a 404 error if the record cannot be loaded
  • It reverses the order of the characters in a string
  • It constructs the path to a view using the name of a path entry in urls.py

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


These are Building Web Applications in Django Week 4 Answers Coursera Quiz


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?

  • The record is automatically created but left empty
  • The server crashes and sends you a 500
  • You get a 404
  • You get a 200

Answer: 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?

  • The favicon will not show up properly in the title bar
  • The form will look strange in the user’s browser
  • The server will not know which object to retrieve once the POST data is sent
  • The POST data will be blocked by the server

Answer: The POST data will be blocked by the server


These are Building Web Applications in Django Week 4 Answers Coursera Quiz


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?

  • forloop.counter
  • url ‘polls:vote’ question.id
  • choice.choice_text
  • question.question_text

Answer: url ‘polls:vote’ question.id


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

  • 404
  • GET
  • POST
  • 200

Answer: POST


These are Building Web Applications in Django Week 4 Answers Coursera Quiz


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

  • It converts a word to the plural form depending on the user’s selected language
  • It returns a random item from the given list
  • It splits a string using a specific delimiter character
  • It emits an ‘s’ if the value is > 1

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


Forms and HTML

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

  • GET
  • POST
  • 200
  • 404

Answer: GET


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

  • GET
  • POST
  • 200
  • 404

Answer: POST


These are Building Web Applications in Django Week 4 Answers Coursera Quiz


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

  • dictionary
  • list
  • string
  • tuple

Answer: dictionary


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

  • Using the socket after the request headers have been sent
  • Using a second socket connection
  • At the end of the Content-Type request header
  • Appended to the URL after a question mark

Answer: Using the socket after the request headers have been sent


These are Building Web Applications in Django Week 4 Answers Coursera Quiz


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

  • True
  • False

Answer: False


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

  • True
  • False

Answer: False


These are Building Web Applications in Django Week 4 Answers Coursera Quiz


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

  • They use the same name parameter
  • They come right after one another in the HTML
  • They are part of a radio-group tag
  • They must be in the same paragraph (p tag)

Answer: 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?

  • 403
  • 302
  • 500
  • 200

Answer: 403


These are Building Web Applications in Django Week 4 Answers Coursera Quiz


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

  • 302
  • 200
  • 403
  • 500

Answer: 302


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

  • To avoid triggering the browser double-POST popup
  • To handle files as attachments
  • To make sure that cookies are not stolen
  • To validate incoming data in a form

Answer: To avoid triggering the browser double-POST popup


These are Building Web Applications in Django Week 4 Answers Coursera Quiz


More Weeks of this course: Click Here

More Coursera Courses: http://progiez.com/coursera


These are Building Web Applications in Django Week 4 Answers Coursera Quiz
The content uploaded on this website is for reference purposes only. Please do it yourself first.