Django notes-generic views

Source: Internet
Author: User

Generic views

1. First glance at generic views
Generic views are actually a set of views functions, but these views functions are awesome.
Help me write it. You can use it. This is more like a views library, but it focuses more on the following
Situations:
1) complete a simple task, redirect to a different page, or render a template
2) display the list and detail pages of an object.
View functions (Chapter 1)
3) display the page for archiving database objects by year, month, or day. This is similar to archiving objects by year, month, or day in a blog.
What generic views is good.

2. Generic views function.

Def direct_to_template (request, template, extra_context = none, mimetype = none, ** kwargs)

Def redirect_to (request, URL, permanent = true, ** kwargs)

Def object_detail (request, queryset, object_id = none, slug = none,
Slug_field = 'slug', template_name = none, template_name_field = none,
Template_loader = loader, extra_context = none,
Context_processors = none, template_object_name = 'object ',
Mimetype = none)

Def object_list (request, queryset, paginate_by = none, page = none,
Allow_empty = true, template_name = none, template_loader = loader,
Extra_context = none, context_processors = none, template_object_name = 'object ',
Mimetype = none)

Def archive_index (request, queryset, date_field, num_latest = 15,
Template_name = none, template_loader = loader,
Extra_context = none, allow_empty = true, context_processors = none,
Mimetype = none, allow_future = false, template_object_name = 'latest ')

Def archive_year (request, year, queryset, date_field, template_name = none,
Template_loader = loader, extra_context = none, allow_empty = false,
Context_processors = none, template_object_name = 'object', mimetype = none,
Make_object_list = false, allow_future = false)

............
When these functions are used, you can look at the Django code implementation.
It is quite convenient.

<End of this section>

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.