| 507 | ``db_column`` |
| 508 | ~~~~~~~~~~~~~ |
| 509 | |
| 510 | The name of the database column to use for this field. If this isn't given, |
| 511 | Django will use the field's name. |
| 512 | |
| 513 | If your database column name is an SQL reserved word, or contains |
| 514 | characters that aren't allowed in Python variable names -- notably, the |
| 515 | hyphen -- that's OK. Django quotes column and table names behind the |
| 516 | scenes. |
| 517 | |
| 518 | ``db_index`` |
| 519 | ~~~~~~~~~~~~ |
| 520 | |
| 521 | If ``True``, ``django-admin.py sqlindexes`` will output a ``CREATE INDEX`` |
| 522 | statement for this field. |
| 523 | |
| 524 | ``primary_key`` |
| 525 | ~~~~~~~~~~~~~~~ |
| 526 | |
| 527 | If ``True``, this field is the primary key for the model. |
| 528 | |
| 529 | If you don't specify ``primary_key=True`` for any fields in your model, |
| 530 | Django will automatically add this field:: |
| 531 | |
| 532 | id = models.AutoField('ID', primary_key=True) |
| 533 | |
| 534 | Thus, you don't need to set ``primary_key=True`` on any of your fields |
| 535 | unless 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 | |
| 543 | If ``True``, this field must be unique throughout the table. |
| 544 | |
| 545 | This is enforced at the database level and at the Django admin-form level. |
| 546 | |
| 547 | Field meta options |
| 548 | ------------------ |
| 549 | |
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 | | |
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 | | |