利用 Django DetailView 生成单页官方文档

url.py 的配置

#urls.py
from myproject.views import MyDetailView    #导入 detailview
urlpatterns = [
    url(r'^(?P<slug>[\w|\-]+)/$', 
        MyDetailView.as_view(template_name='detail.html'), 
        name='detail'),
]
#views.py  
from myproject.models import MyModel
from django.views.generic import DetailView
class MyDetailView(DetailView):
    model         = MyModel
    slug_field    = 'slug'

DetailView

Render a detail view of an object.

Attributes:

- content_type
- context_object_name- http_method_names
- model
- pk_url_kwarg
- queryset
- response_class
- slug_field
- slug_url_kwarg
- template_name
- template_name_field
- template_name_suffix

Methods:

- def _allowed_methods(self):
- def as_view(cls, **initkwargs):
- def dispatch(self, request, *args, **kwargs):
- def get(self, request, *args, **kwargs):
- def get_context_data(self, **kwargs):
- def get_context_object_name(self, obj):
- def get_object(self, queryset=None):
- def get_queryset(self):
- def get_slug_field(self):
- def get_template_names(self):
- def http_method_not_allowed(self, request, *args, **kwargs):
- def __init__(self, **kwargs):
- def options(self, request, *args, **kwargs):
- def render_to_response(self, context, **response_kwargs):