Archive_year of Django generic view

Source: Internet
Author: User

Develop network applicationsProgramSometimes it is monotonous, because we repeat some operations (or modes), and it is boring to do more repetitive tasks. In Django, such common operations have been abstracted as generic views (general views ). Using generic views, we do not need to write a line of PythonCodeYou can provide some common view operations. For example:

 
  Django. Views. Generic. date_based.archive_year
Django. Views. Generic. date_based.archive_month
Django. Views. Generic. date_based.archive_week
Django. Views. Generic. date_based.archive_day
Django. Views. Generic. date_based.archive_today
Django. Views. Generic. date_based.object_detail

And so on.

archive_year is special in this type of generic views, because make_object_list, which is not included in other generic views, according to Django's official statement, when make_object_list is true, A list of all related records in the year will be passed to the corresponding template, the list name is specified by template_object_name + "_ List" (object_list by default); if If make_object_list is false, the list in the input template is empty, regardless of the number of related records. It's strange that I don't know why Django adopts this policy. Therefore, when using the archive_year generic view, pay special attention to the value of make_object_list.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.