官方快捷链接

django http


Django如何处理一个http请求

404,403,500错误

Including other URLconfs语法

Reverse resolution of URLs 反向解析

URL namespaces命名空间

A simple view

Returning errors返回错误

Customizing error views自定义错误页面

View decorators views装饰器

File Uploads 文件上传

Django shortcut functions django内置快简函数

Middleware 中间件

How to use sessions

Working with forms

Rendering fields manually

Formsets

Creating forms from models

Overriding the default fields 重写form字段 自定义、错误信息、样式

Changing the queryset 修改modelform中的queryset

Changing the form modelform 中的clean

Saving objects in the formset

Using a model formset in a view

Form Assets (the Media class)

Templates


Class-based views


Using class-based views

Using mixins

Handling forms with class-based views

Decorating the class cbv装饰器

Built-in class-based generic views 内置通用CBV

Generic views of objects

Adding extra context

Viewing subsets of objects 设定queryset

Dynamic filtering 动态过滤

Performing extra work 动态更新一些信息

Form handling with class-based views

Basic forms

Notes:

Model forms views + form = formview

You don’t even need to provide a success_url for CreateView or UpdateView - they will use get_absolute_url() on the model object if available.

Models and request.user 额外添加数据

AJAX example

Using mixins with class-based views

For this reason, Django also provides a number of mixins that provide more discrete functionality. Template rendering, for instance, is encapsulated in the TemplateResponseMixin. The Django reference documentation contains full documentation of all the mixins.

Using SingleObjectMixin with View

Using SingleObjectMixin with ListView

Using FormMixin with DetailView

More than just HTML