Ticket #4737: 4737.patch

File 4737.patch, 3.8 KB (added by Chris Beaven, 17 years ago)

as a trac readable diff (and a couple of minor changes)

  • docs/model-api.txt

     
    471471Field options
    472472-------------
    473473
    474 The following arguments are available to all field types. All are optional.
     474All field types can take a number of options. These are split into two main
     475categories; `field database options`_ which affect how the field is represented
     476in the database, and `field meta options`_ which affect the field's display and
     477validation. These meta options are only used by components which recognise
     478them, i.e. the admin interface and the form component.
    475479
     480Field database options
     481----------------------
     482
    476483``null``
    477484~~~~~~~~
    478485
     
    497504    be coerced for string-based fields that can blank, and the value
    498505    ``NULL`` will be stored to denote the empty string.
    499506
     507``db_column``
     508~~~~~~~~~~~~~
     509
     510The name of the database column to use for this field. If this isn't given,
     511Django will use the field's name.
     512
     513If your database column name is an SQL reserved word, or contains
     514characters that aren't allowed in Python variable names -- notably, the
     515hyphen -- that's OK. Django quotes column and table names behind the
     516scenes.
     517
     518``db_index``
     519~~~~~~~~~~~~
     520
     521If ``True``, ``django-admin.py sqlindexes`` will output a ``CREATE INDEX``
     522statement for this field.
     523
     524``primary_key``
     525~~~~~~~~~~~~~~~
     526
     527If ``True``, this field is the primary key for the model.
     528
     529If you don't specify ``primary_key=True`` for any fields in your model,
     530Django will automatically add this field::
     531
     532    id = models.AutoField('ID', primary_key=True)
     533
     534Thus, you don't need to set ``primary_key=True`` on any of your fields
     535unless you want to override the default primary-key behavior.
     536
     537``primary_key=True`` implies ``blank=False``, ``null=False`` and
     538``unique=True``. Only one primary key is allowed on an object.
     539
     540``unique``
     541~~~~~~~~~~
     542
     543If ``True``, this field must be unique throughout the table.
     544
     545This is enforced at the database level and at the Django admin-form level.
     546
     547Field meta options
     548------------------
     549
    500550``blank``
    501551~~~~~~~~~
    502552
     
    574624Django admin site. Essentially, this means you should put ``core=True`` on all
    575625required fields in your related object that is being edited inline.
    576626
    577 ``db_column``
    578 ~~~~~~~~~~~~~
    579 
    580 The name of the database column to use for this field. If this isn't given,
    581 Django will use the field's name.
    582 
    583 If your database column name is an SQL reserved word, or contains
    584 characters that aren't allowed in Python variable names -- notably, the
    585 hyphen -- that's OK. Django quotes column and table names behind the
    586 scenes.
    587 
    588 ``db_index``
    589 ~~~~~~~~~~~~
    590 
    591 If ``True``, ``django-admin.py sqlindexes`` will output a ``CREATE INDEX``
    592 statement for this field.
    593 
    594627``db_tablespace``
    595628~~~~~~~~~~~~~~~~~
    596629
     
    620653form. It's useful for documentation even if your object doesn't have an
    621654admin form.
    622655
    623 ``primary_key``
    624 ~~~~~~~~~~~~~~~
    625 
    626 If ``True``, this field is the primary key for the model.
    627 
    628 If you don't specify ``primary_key=True`` for any fields in your model,
    629 Django will automatically add this field::
    630 
    631     id = models.AutoField('ID', primary_key=True)
    632 
    633 Thus, you don't need to set ``primary_key=True`` on any of your fields
    634 unless you want to override the default primary-key behavior.
    635 
    636 ``primary_key=True`` implies ``blank=False``, ``null=False`` and
    637 ``unique=True``. Only one primary key is allowed on an object.
    638 
    639656``radio_admin``
    640657~~~~~~~~~~~~~~~
    641658
     
    646663Don't use this for a field unless it's a ``ForeignKey`` or has ``choices``
    647664set.
    648665
    649 ``unique``
    650 ~~~~~~~~~~
    651 
    652 If ``True``, this field must be unique throughout the table.
    653 
    654 This is enforced at the database level and at the Django admin-form level.
    655 
    656666``unique_for_date``
    657667~~~~~~~~~~~~~~~~~~~
    658668
Back to Top