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>