<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 內建基于類的視圖的API # 基于類的視圖的API 參考。另請參見[基于類的視圖](http://python.usyiyi.cn/django/topics/class-based-views/index.html) 的簡介。 + [基礎視圖](http://python.usyiyi.cn/django/ref/class-based-views/base.html) + [View](http://python.usyiyi.cn/django/ref/class-based-views/base.html#view) + [TemplateView](http://python.usyiyi.cn/django/ref/class-based-views/base.html#templateview) + [RedirectView](http://python.usyiyi.cn/django/ref/class-based-views/base.html#redirectview) + [通用的顯示視圖](http://python.usyiyi.cn/django/ref/class-based-views/generic-display.html) + [DetailView](http://python.usyiyi.cn/django/ref/class-based-views/generic-display.html#detailview) + [ListView](http://python.usyiyi.cn/django/ref/class-based-views/generic-display.html#listview) + [通用的編輯視圖](http://python.usyiyi.cn/django/ref/class-based-views/generic-editing.html) + [FormView](http://python.usyiyi.cn/django/ref/class-based-views/generic-editing.html#formview) + [CreateView](http://python.usyiyi.cn/django/ref/class-based-views/generic-editing.html#createview) + [UpdateView](http://python.usyiyi.cn/django/ref/class-based-views/generic-editing.html#updateview) + [DeleteView](http://python.usyiyi.cn/django/ref/class-based-views/generic-editing.html#deleteview) + [通用的日期視圖](http://python.usyiyi.cn/django/ref/class-based-views/generic-date-based.html) + [ArchiveIndexView](http://python.usyiyi.cn/django/ref/class-based-views/generic-date-based.html#archiveindexview) + [YearArchiveView](http://python.usyiyi.cn/django/ref/class-based-views/generic-date-based.html#yeararchiveview) + [MonthArchiveView](http://python.usyiyi.cn/django/ref/class-based-views/generic-date-based.html#montharchiveview) + [WeekArchiveView](http://python.usyiyi.cn/django/ref/class-based-views/generic-date-based.html#weekarchiveview) + [DayArchiveView](http://python.usyiyi.cn/django/ref/class-based-views/generic-date-based.html#dayarchiveview) + [TodayArchiveView](http://python.usyiyi.cn/django/ref/class-based-views/generic-date-based.html#todayarchiveview) + [DateDetailView](http://python.usyiyi.cn/django/ref/class-based-views/generic-date-based.html#datedetailview) + [基于類的視圖的Mixins](http://python.usyiyi.cn/django/ref/class-based-views/mixins.html) + [Simple mixins](http://python.usyiyi.cn/django/ref/class-based-views/mixins-simple.html) + [ContextMixin](http://python.usyiyi.cn/django/ref/class-based-views/mixins-simple.html#contextmixin) + [TemplateResponseMixin](http://python.usyiyi.cn/django/ref/class-based-views/mixins-simple.html#templateresponsemixin) + [Single object mixins](http://python.usyiyi.cn/django/ref/class-based-views/mixins-single-object.html) + [SingleObjectMixin](http://python.usyiyi.cn/django/ref/class-based-views/mixins-single-object.html#singleobjectmixin) + [SingleObjectTemplateResponseMixin](http://python.usyiyi.cn/django/ref/class-based-views/mixins-single-object.html#singleobjecttemplateresponsemixin) + [Multiple object mixins](http://python.usyiyi.cn/django/ref/class-based-views/mixins-multiple-object.html) + [MultipleObjectMixin](http://python.usyiyi.cn/django/ref/class-based-views/mixins-multiple-object.html#multipleobjectmixin) + [MultipleObjectTemplateResponseMixin](http://python.usyiyi.cn/django/ref/class-based-views/mixins-multiple-object.html#multipleobjecttemplateresponsemixin) + [Editing mixins](http://python.usyiyi.cn/django/ref/class-based-views/mixins-editing.html) + [FormMixin](http://python.usyiyi.cn/django/ref/class-based-views/mixins-editing.html#formmixin) + [ModelFormMixin](http://python.usyiyi.cn/django/ref/class-based-views/mixins-editing.html#modelformmixin) + [ProcessFormView](http://python.usyiyi.cn/django/ref/class-based-views/mixins-editing.html#processformview) + [DeletionMixin](http://python.usyiyi.cn/django/ref/class-based-views/mixins-editing.html#deletionmixin) + [Date-based mixins](http://python.usyiyi.cn/django/ref/class-based-views/mixins-date-based.html) + [YearMixin](http://python.usyiyi.cn/django/ref/class-based-views/mixins-date-based.html#yearmixin) + [MonthMixin](http://python.usyiyi.cn/django/ref/class-based-views/mixins-date-based.html#monthmixin) + [DayMixin](http://python.usyiyi.cn/django/ref/class-based-views/mixins-date-based.html#daymixin) + [WeekMixin](http://python.usyiyi.cn/django/ref/class-based-views/mixins-date-based.html#weekmixin) + [DateMixin](http://python.usyiyi.cn/django/ref/class-based-views/mixins-date-based.html#datemixin) + [BaseDateListView](http://python.usyiyi.cn/django/ref/class-based-views/mixins-date-based.html#basedatelistview) + [基于類的通用視圖 —— 索引](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html) + [Simple generic views](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#simple-generic-views) + [View](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#view) + [TemplateView](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#templateview) + [RedirectView](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#redirectview) + [Detail Views](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#detail-views) + [DetailView](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#detailview) + [List Views](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#list-views) + [ListView](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#listview) + [Editing views](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#editing-views) + [FormView](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#formview) + [CreateView](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#createview) + [UpdateView](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#updateview) + [DeleteView](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#deleteview) + [Date-based views](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#date-based-views) + [ArchiveIndexView](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#archiveindexview) + [YearArchiveView](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#yeararchiveview) + [MonthArchiveView](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#montharchiveview) + [WeekArchiveView](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#weekarchiveview) + [DayArchiveView](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#dayarchiveview) + [TodayArchiveView](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#todayarchiveview) + [DateDetailView](http://python.usyiyi.cn/django/ref/class-based-views/flattened-index.html#datedetailview) ## 說明 ## 由基于類的視圖處理的每個請求都具有一個獨立的狀態;所以,在實例中保存狀態變量是安全的(例如,`self.foo = 3` 是線程安全的操作)。 基于類的視圖在URL 模式中的部署使用`as_view()` 類方法: ``` urlpatterns = [ url(r'^view/$', MyView.as_view(size=42)), ] ``` > 視圖參數的線程安全性 > > 傳遞給視圖的參數在視圖的每個實例之間共享。這表示不應該使用列表、字典或其它可變對象作為視圖的參數。如果你真這么做而且對共享的對象做過修改,某個用戶的行為可能對后面訪問同一個視圖的用戶產生影響。 傳遞給`as_view()` 的參數將賦值給服務請求的實例。利用前面的例子,這表示對`MyView `的每個請求都可以使用 `self.size`。參數必須對應于在類中已經存在的屬性(`hasattr` 檢查可以返回`True`)。 ## 基礎視圖 VS. 通用視圖 ## 基于類的基礎視圖可以認為是父視圖,它們可以直接使用或者繼承它們。它們不能滿足項目中所有的需求,在這種情況下有Mixin 可以擴展基礎視圖的功能。 Django 的通用視圖建立在基礎視圖之上,用于作為經常用到的功能的快捷方式,例如顯示對象的詳細信息。它們提煉視圖開發中常見的風格和模式并將它們抽象,這樣你可以快速編寫常見的視圖而不用重復你自己。 大部分通常視圖需要`queryset` 鍵 ,它是一個`查詢集` 實例;關于`查詢集`對象的更多信息,請參見執行查詢。 > 譯者:[Django 文檔協作翻譯小組](http://python.usyiyi.cn/django/index.html),原文:[API reference](https://docs.djangoproject.com/en/1.8/ref/class-based-views/)。 > > 本文以 [CC BY-NC-SA 3.0](http://creativecommons.org/licenses/by-nc-sa/3.0/cn/) 協議發布,轉載請保留作者署名和文章出處。 > > [Django 文檔協作翻譯小組](http://python.usyiyi.cn/django/index.html)人手緊缺,有興趣的朋友可以加入我們,完全公益性質。交流群:467338606。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看