久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    1. <tfoot id='hE3TD'></tfoot>
    2. <legend id='hE3TD'><style id='hE3TD'><dir id='hE3TD'><q id='hE3TD'></q></dir></style></legend>

      <small id='hE3TD'></small><noframes id='hE3TD'>

      • <bdo id='hE3TD'></bdo><ul id='hE3TD'></ul>
      1. <i id='hE3TD'><tr id='hE3TD'><dt id='hE3TD'><q id='hE3TD'><span id='hE3TD'><b id='hE3TD'><form id='hE3TD'><ins id='hE3TD'></ins><ul id='hE3TD'></ul><sub id='hE3TD'></sub></form><legend id='hE3TD'></legend><bdo id='hE3TD'><pre id='hE3TD'><center id='hE3TD'></center></pre></bdo></b><th id='hE3TD'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='hE3TD'><tfoot id='hE3TD'></tfoot><dl id='hE3TD'><fieldset id='hE3TD'></fieldset></dl></div>

        Django 模型與Python 類屬性

        Django models amp; Python class attributes(Django 模型與Python 類屬性)
          <bdo id='6s28M'></bdo><ul id='6s28M'></ul>
          <legend id='6s28M'><style id='6s28M'><dir id='6s28M'><q id='6s28M'></q></dir></style></legend>

            <small id='6s28M'></small><noframes id='6s28M'>

              <tbody id='6s28M'></tbody>

            <tfoot id='6s28M'></tfoot>
            <i id='6s28M'><tr id='6s28M'><dt id='6s28M'><q id='6s28M'><span id='6s28M'><b id='6s28M'><form id='6s28M'><ins id='6s28M'></ins><ul id='6s28M'></ul><sub id='6s28M'></sub></form><legend id='6s28M'></legend><bdo id='6s28M'><pre id='6s28M'><center id='6s28M'></center></pre></bdo></b><th id='6s28M'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='6s28M'><tfoot id='6s28M'></tfoot><dl id='6s28M'><fieldset id='6s28M'></fieldset></dl></div>

                1. 本文介紹了Django 模型與Python 類屬性的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  django 網(wǎng)站上的教程顯示了模型的以下代碼:

                  The tutorial on the django website shows this code for the models:

                  from django.db import models
                  
                  class Poll(models.Model):
                      question = models.CharField(max_length=200)
                      pub_date = models.DateTimeField('date published')
                  
                  class Choice(models.Model):
                      poll = models.ForeignKey(Poll)
                      choice = models.CharField(max_length=200)
                      votes = models.IntegerField()
                  

                  現(xiàn)在,這些屬性中的每一個(gè)都是類屬性,對吧?因此,該類的所有實(shí)例都應(yīng)共享相同的屬性.稍后,他們展示了這段代碼:

                  Now, each of those attribute, is a class attribute, right? So, the same attribute should be shared by all instances of the class. A bit later, they present this code:

                  class Poll(models.Model):
                      # ...
                      def __unicode__(self):
                          return self.question
                  
                  class Choice(models.Model):
                      # ...
                      def __unicode__(self):
                          return self.choice
                  

                  它們是如何從類屬性轉(zhuǎn)變?yōu)閷?shí)例屬性的?我是不是把類屬性弄錯(cuò)了?

                  How did they turn from class attributes into instance attributes? Did I get class attributes wrong?

                  推薦答案

                  看看django/db/models.py下的Model類.在那里,類屬性通過類似的方式轉(zhuǎn)換為實(shí)例屬性

                  Have a look at the Model class under django/db/models.py. There the class attributes are turned to instance attributes via something like

                  setattr(self, field.attname, val)
                  

                  人們可能會推薦整個(gè)文件(ModelBaseModel 類)作為元類的優(yōu)秀實(shí)踐示例.

                  One might recommend the whole file (ModelBase and Model class) as an excellent hands-on example on metaclasses.

                  這篇關(guān)于Django 模型與Python 類屬性的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  python: Two modules and classes with the same name under different packages(python:不同包下同名的兩個(gè)模塊和類)
                  Configuring Python to use additional locations for site-packages(配置 Python 以使用站點(diǎn)包的其他位置)
                  How to structure python packages without repeating top level name for import(如何在不重復(fù)導(dǎo)入頂級名稱的情況下構(gòu)造python包)
                  Install python packages on OpenShift(在 OpenShift 上安裝 python 包)
                  How to refresh sys.path?(如何刷新 sys.path?)
                  Distribute a Python package with a compiled dynamic shared library(分發(fā)帶有已編譯動態(tài)共享庫的 Python 包)
                2. <small id='rbKbA'></small><noframes id='rbKbA'>

                  • <bdo id='rbKbA'></bdo><ul id='rbKbA'></ul>

                    <legend id='rbKbA'><style id='rbKbA'><dir id='rbKbA'><q id='rbKbA'></q></dir></style></legend>
                    <i id='rbKbA'><tr id='rbKbA'><dt id='rbKbA'><q id='rbKbA'><span id='rbKbA'><b id='rbKbA'><form id='rbKbA'><ins id='rbKbA'></ins><ul id='rbKbA'></ul><sub id='rbKbA'></sub></form><legend id='rbKbA'></legend><bdo id='rbKbA'><pre id='rbKbA'><center id='rbKbA'></center></pre></bdo></b><th id='rbKbA'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='rbKbA'><tfoot id='rbKbA'></tfoot><dl id='rbKbA'><fieldset id='rbKbA'></fieldset></dl></div>

                          <tfoot id='rbKbA'></tfoot>
                            <tbody id='rbKbA'></tbody>
                            主站蜘蛛池模板: 看亚洲a级一级毛片 | 国产一区二区在线播放 | aaa大片免费观看 | 成人毛片网 | 亚洲国产免费 | 狠狠躁夜夜躁人人爽天天高潮 | 成人精品鲁一区一区二区 | 7777精品伊人久久精品影视 | 日韩成人专区 | 国产精品美女久久久av超清 | 国产精品一区二区三 | 7777在线视频免费播放 | 久久噜噜噜精品国产亚洲综合 | 久久久中文 | 国产在线视频一区 | 欧美日一区 | 国产99视频精品免视看9 | 欧美日韩一区精品 | 久久精品女人天堂av | 午夜影院在线视频 | 国产一区二区三区 | 精品美女在线观看视频在线观看 | 91在线网站 | 欧美国产一区二区 | 青青草免费在线视频 | 一区二区在线不卡 | 成人久久18免费网站 | 亚洲精品播放 | 免费视频99 | 香蕉大人久久国产成人av | 亚洲精品一区二区网址 | 狠狠久久久| 久久精品一区 | 91在线精品一区二区 | 99精品欧美一区二区三区综合在线 | 国产美女视频一区 | 欧美欧美欧美 | 日日操日日舔 | 一级a性色生活片久久毛片波多野 | 欧美xxxx黑人又粗又长 | 国产日韩欧美中文字幕 |