Django Features and Libraries | Week 5

Course Name: Django for Everybody

Sub-course: Django Features and Libraries

Course Link: Django for Everybody

Sub-course Link: Django Features and Libraries

These are Django Features and Libraries Week 5 Answers Coursera Quiz


Owned Rows

Q1. Why do we insist on producing a delete confirmation screen?

  • Because a GET request should never modify data
  • Because a POST request cannot modify data
  • To make sure that there are no JavaScript errors
  • Because Django would not be able to delete the data

Answer: Because a GET request should never modify data


Q2. Which of the following methods is called first in the Django generic list view?

  • startup
  • get_queryset()
  • setup()
  • get()
  • render_to_response()

Answer: setup()


These are Django Features and Libraries Week 5 Answers Coursera Quiz


Q3. Which method do we override in the Django generic list view to keep users from making changes to rows they don’t own?

  • render_to_response()
  • startup
  • setup()
  • get()
  • get_queryset()

Answer: get_queryset()


Q4. What does OwnerUpdateView do if a user tries to delete a record that does not belong to them?

  • It returns a 404 (not found error)
  • It puts out an error message in the JavaScript console
  • It stops and fails with an error log message
  • It redirects the user to www.djangoproject.org

Answer: It returns a 404 (not found error)


These are Django Features and Libraries Week 5 Answers Coursera Quiz


Q5. What template variable indicates the current logged-in user?

  • user
  • article.owner
  • myarts.owner
  • tsugi.user
  • request.user

Answer: user


Q6. What is the name of the model that Django uses to store User objects?

  • settings.AUTH_USER_MODEL
  • django.users
  • DjangoUsers
  • settings.USERS
  • Users

Answer: settings.AUTH_USER_MODEL


These are Django Features and Libraries Week 5 Answers Coursera Quiz

See also  Web Application Technologies and Django | Week 1

Q7. What is the database relationship between the Article model and User model?

  • Zero-to-Zero
  • One-to-Many
  • One-to-One
  • Many-to-Many

Answer: One-to-Many


Q8. In views.py in the myarts sample code, what is the purpose of the “fields” class-wide value?

  • To limit the model fields displayed in the form
  • To make the listed fields un-editable
  • To list the fields that will be autosaved
  • To double-check that model fields are not missing

Answer: To limit the model fields displayed in the form


These are Django Features and Libraries Week 5 Answers Coursera Quiz


Q9. For a data model named Frog, what is the generic Edit View convention for the template used when editing a Frog object?

  • frog_update.html
  • frog_modify.html
  • frog_form.html
  • frog_edit.html

Answer: frog_form.html


Q10. In the OwnerCreateView class, what method is overridden to set the “owner” field to the current logged-in user?

  • LoginRequiredMixin
  • save(commit=False)
  • form_valid()
  • add_owner()

Answer: form_valid()


These are Django Features and Libraries Week 5 Answers Coursera Quiz


Q11. In OwnerUpdateView, how do we make sure that the current logged-in user cannot retrieve any rows that don’t belong to them?

  • We add a model filter
  • We intercept the SQL and add a WHERE clause
  • We call the method of the same name in the super class
  • We retrieve all the objects and throw away the non-owned objects

Answer: We add a model filter


Q12. In OwnerUpdateView, which is the “super” or “parent” class?

  • OwnerUpdateView
  • get_queryset()
  • SuperUpdateView
  • UpdateView::Super
  • UpdateView

Answer: UpdateView


These are Django Features and Libraries Week 5 Answers Coursera Quiz


Q13. When a generic edit view is receiving POST data, which of the following steps is done first?

  • get_query_set()
  • pre_post()
  • form_valid()
  • clean()
  • first_post()
See also  Django Features and Libraries | Week 6

Answer: clean()


These are Django Features and Libraries Week 5 Answers Coursera Quiz


More Weeks of this course: Click Here

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


These are Django Features and Libraries Week 5 Answers Coursera Quiz