DetailView is the first view where we're going to be interacting with the database. It builds upon TemplateView, and then adds a bunch of functionality based around showing that model instance.

Order of Operation

  1. get - The get method calls get_object method and get_context_data before rendering
  2. get_object - fetch the object that will be displayed using either the pk or slug passed in through the URL
  3. get_queryset - determine an object list of instances to be able to pick from. This is used when you want to limit the possible options, such as only choosing active articles.
  4. get_template_names - find the template that should be rendered. This method is overridden to give a default template name such as `articles/article_detail.html'. However, if we specify the `template_name` property on the class it will use that template.
  5. get_context_data - put the object into the context data to make it available for use in the template.
  6. get_context_object_name - called within get_context_data to return the context name to use in the templates. This is why the name of the model, such as article, is available for use in the template.
  7. get_slug_field - if you are filtering the URL by a slug field, this what determines which field to use. In our example we would use the article.title field to filter.