mirror of
https://github.com/django/django.git
synced 2025-03-06 15:32:33 +00:00
[4.2.x] Fixed #34310 -- Added deletion example to one-to-one topic.
Backport of 7c6195ef81075b03a704431b5d08ec597e8573f7 from main
This commit is contained in:
parent
d70b2a88e8
commit
9306a8d18f
@ -137,6 +137,16 @@ This also works in reverse::
|
||||
>>> Place.objects.get(restaurant__place__name__startswith="Demon")
|
||||
<Place: Demon Dogs the place>
|
||||
|
||||
If you delete a place, its restaurant will be deleted (assuming that the
|
||||
``OneToOneField`` was defined with
|
||||
:attr:`~django.db.models.ForeignKey.on_delete` set to ``CASCADE``, which is the
|
||||
default)::
|
||||
|
||||
>>> p2.delete()
|
||||
(2, {'one_to_one.Restaurant': 1, 'one_to_one.Place': 1})
|
||||
>>> Restaurant.objects.all()
|
||||
<QuerySet [<Restaurant: Demon Dogs the restaurant>]>
|
||||
|
||||
Add a Waiter to the Restaurant::
|
||||
|
||||
>>> w = r.waiter_set.create(name='Joe')
|
||||
|
Loading…
x
Reference in New Issue
Block a user