mirror of
https://github.com/django/django.git
synced 2025-07-09 20:29:12 +00:00
Added cliff688's more concise explanation.
Co-authored-by: Clifford Gama <53076065+cliff688@users.noreply.github.com>
This commit is contained in:
parent
4cf8913fae
commit
0a02e4e3c4
@ -154,9 +154,11 @@ A :class:`~django.db.models.Field` can also have various optional arguments; in
|
|||||||
this case, we've set the :attr:`~django.db.models.Field.default` value of
|
this case, we've set the :attr:`~django.db.models.Field.default` value of
|
||||||
``votes`` to 0.
|
``votes`` to 0.
|
||||||
|
|
||||||
Finally, note that a relationship is defined, using
|
Finally, note that a :class:`~django.db.models.ForeignKey` defines a
|
||||||
:class:`~django.db.models.ForeignKey`. That tells Django that each ``Choice`` is
|
relationship between models. This creates a one-to-many relationship, where
|
||||||
related to a single ``Question``. However, this doesn't mean that each ``Question`` is related to only one ``Choice``. One ``Question`` could have many ``Choice`` instances related to it. As a result, this relationship would be defined as many-to-one. Django supports all the common database
|
a ``Question`` can have multiple related ``Choice`` instances. Django supports
|
||||||
|
all the common database relationships: many-to-one, many-to-many, and
|
||||||
|
one-to-one.
|
||||||
relationships: many-to-one, many-to-many, and one-to-one.
|
relationships: many-to-one, many-to-many, and one-to-one.
|
||||||
|
|
||||||
Activating models
|
Activating models
|
||||||
|
Loading…
x
Reference in New Issue
Block a user