tanteng
V2EX  ›  Django

Django 模型字段有哪些方法?

  •  
  •   tanteng ·
    tanteng · May 14, 2015 · 4433 views
    This topic created in 4051 days ago, the information mentioned may be changed or developed.

    class Question(models.Model):
    question_text = models.CharField(max_length=200)

    怎么看models有哪些属性??是不是很弱的问题,我知道看源码可以,我是想看看有没有更好的通常的方式,谢谢!

    models.CharField(max_length=200)
    有哪些字段和后面的参数

    18 replies    2015-06-21 22:36:33 +08:00
    gamexg
        1
    gamexg  
       May 14, 2015 via Android
    Dj. 文档
    Septembers
        2
    Septembers  
       May 14, 2015   ❤️ 1
    codegeek
        3
    codegeek  
       May 14, 2015
    read the fuck manuel
    imlonghao
        4
    imlonghao  
       May 14, 2015 via Android
    Please take a look at the fucking document.
    braineo
        5
    braineo  
       May 14, 2015
    UTFG
    Septembers
        6
    Septembers  
       May 14, 2015
    @braineo UTFG是什么鬼?是什么的缩写?
    CodeDrift
        7
    CodeDrift  
       May 14, 2015
    下个IDE。。。。自动提示
    est
        8
    est  
       May 14, 2015   ❤️ 1
    @Septembers Uninstall the fucking game
    Itanium
        9
    Itanium  
       May 14, 2015   ❤️ 1
    $ python manage shell

    from django.db import models
    dir(models)

    只是看属性
    braineo
        10
    braineo  
       May 14, 2015   ❤️ 1
    @Septembers 是个递归性的回答--UTFG

    UTFG--Use The Fucking Google

    @est Good Job
    sinux
        11
    sinux  
       May 14, 2015
    昨天在stack上回答这个问题....
    tanteng
        12
    tanteng  
    OP
       May 14, 2015
    @Septembers 我就知道有人这么回答
    tanteng
        13
    tanteng  
    OP
       May 14, 2015
    @Itanium 这才是我要的答案
    tanteng
        14
    tanteng  
    OP
       May 14, 2015
    @Itanium
    >>> from django.db import models
    >>> dir(models)
    ['Aggregate', 'AutoField', 'Avg', 'BLANK_CHOICE_DASH', 'BigIntegerField', 'Binar
    yField', 'BooleanField', 'CASCADE', 'Case', 'CharField', 'CommaSeparatedIntegerF
    ield', 'Count', 'DO_NOTHING', 'DateField', 'DateTimeField', 'DecimalField', 'Dur
    ationField', 'EmailField', 'Empty', 'Expression', 'ExpressionWrapper', 'F', 'Fie
    ld', 'FieldDoesNotExist', 'FileField', 'FilePathField', 'FloatField', 'ForeignKe
    y', 'ForeignObject', 'Func', 'GenericIPAddressField', 'IPAddressField', 'ImageFi
    eld', 'ImproperlyConfigured', 'IntegerField', 'Lookup', 'Manager', 'ManyToManyFi
    eld', 'ManyToManyRel', 'ManyToOneRel', 'Max', 'Min', 'Model', 'NOT_PROVIDED', 'N
    ullBooleanField', 'ObjectDoesNotExist', 'OneToOneField', 'OneToOneRel', 'OrderWr
    t', 'PROTECT', 'PositiveIntegerField', 'PositiveSmallIntegerField', 'Prefetch',
    'ProtectedError', 'Q', 'QuerySet', 'RemovedInDjango19Warning', 'SET', 'SET_DEFAU
    LT', 'SET_NULL', 'SlugField', 'SmallIntegerField', 'StdDev', 'SubfieldBase', 'Su
    m', 'TextField', 'TimeField', 'Transform', 'URLField', 'UUIDField', 'Value', 'Va
    riance', 'When', '__builtins__', '__cached__', '__doc__', '__file__', '__loader_
    _', '__name__', '__package__', '__path__', '__spec__', 'aggregates', 'base', 'co
    nstants', 'deletion', 'expressions', 'fields', 'get_app', 'get_app_path', 'get_a
    pp_paths', 'get_apps', 'get_model', 'get_models', 'lookups', 'manager', 'options
    ', 'permalink', 'query', 'query_utils', 'register_models', 'signals', 'sql', 'sy
    s', 'warnings', 'wraps']
    xixijun
        15
    xixijun  
       May 15, 2015
    dir() 和 help 是个很biang的方法
    Septembers
        16
    Septembers  
       May 15, 2015
    @xixijun dir和help不是python的基本常识么?
    laipogo
        17
    laipogo  
       Jun 1, 2015
    @codegeek
    fucking manual
    dalang
        18
    dalang  
       Jun 21, 2015
    Question._meta.fields or Question._meta.get_fields() # in django 1.8
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   991 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 48ms · UTC 22:07 · PVG 06:07 · LAX 15:07 · JFK 18:07
    ♥ Do have faith in what you're doing.