0.参考

https://docs.djangoproject.com/en/2.1/topics/class-based-views/mixins/

1.版本信息

In [157]: import sys

In [158]: sys.version
Out[158]: '3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)]' In [159]: import django In [160]: django.__version__
Out[160]: '2.1' In [161]: from django.views.generic.detail import DetailView In [162]: DetailView.__mro__
Out[162]:
(django.views.generic.detail.DetailView,
django.views.generic.detail.SingleObjectTemplateResponseMixin,
django.views.generic.base.TemplateResponseMixin,
django.views.generic.detail.BaseDetailView,
django.views.generic.detail.SingleObjectMixin,
django.views.generic.base.ContextMixin,
django.views.generic.base.View,
object)

1.多重继承关系和 MRO

E:\ProgramData\Anaconda3\envs\py3\Lib\site-packages\django\views\generic\detail.py

E:\ProgramData\Anaconda3\envs\py3\Lib\site-packages\django\views\generic\list.py

E:\ProgramData\Anaconda3\envs\py3\Lib\site-packages\django\views\generic\base.py

右下角红色箭头为 path 定义的 .as_view() 入口

绿色箭头代表 MRO,  顺序从左上到右下,由粗到细

Django DetailView 多重继承 关系整理-LMLPHP

05-11 20:19