# Does on\_delete=models.CASCADE applies bidirectionally?

**URL:** <https://forum.djangoproject.com/t/does-on-delete-models-cascade-applies-bidirectionally/29901>\
**Category:** Using the ORM\
**Created:** [April 6, 2024, 12:06pm UTC](https://forum.djangoproject.com/t/does-on-delete-models-cascade-applies-bidirectionally/29901 "2024-04-06T12:06:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaiqahmad](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/shaiqahmad/32/18896_2.png) [@shaiqahmad](https://forum.djangoproject.com/u/shaiqahmad)\
**Post date:** [April 6, 2024, 12:06pm UTC](https://forum.djangoproject.com/t/does-on-delete-models-cascade-applies-bidirectionally/29901/1 "2024-04-06T12:06:14Z")

</div>

Hello there, I have a question; **`on_delete=models.CASCADE` applies bidirectionally?**  
I defined a Profile model with field;

```auto
    user = models.OneToOneField(User, on_delete=models.CASCADE)

```

Here is the full [story](https://forum.djangoproject.com/t/how-to-combine-user-management-with-a-model/29533/8). But experimented this.  
When I delete an instance from User: it is also deleted from Profile.  
However, when I delete an instance from Profile: it is not deleted from User.

Best Regards.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [April 6, 2024, 4:13pm UTC](https://forum.djangoproject.com/t/does-on-delete-models-cascade-applies-bidirectionally/29901/2 "2024-04-06T16:13:14Z")

</div>

No, it doesn’t, and in my opinion, shouldn’t.

Quoting from the comments in the code at [django/django/db/models/fields/related\_descriptors.py at ca5cd3e3e8e53f15e68ccd727ec8fe719cc48099 · django/django · GitHub](https://github.com/django/django/blob/ca5cd3e3e8e53f15e68ccd727ec8fe719cc48099/django/db/models/fields/related_descriptors.py#L40)

> One-to-one relations are asymmetrical, despite the apparent symmetry of the  
> name, because they’re implemented in the database with a foreign key from  
> one table to another.

A OneToOneField is a foreign key with the constraint that the foreign key is unique. (No other row can have a reference to the same object in the referenced model.)

The models.CASCADE option is defined as deleting the object containing the foreign key when the model instance being referenced is deleted.

If the model with the foreign key is deleted, it physically has no effect on the model being referenced. (There are no potential integrity constraint violations created by doing this.)

As a result of this, you do need to consider the “orientation” of one-to-one relationships when defining your models. In a “profile” situation, you _may_ have cases where a “User” doesn’t have a related “Profile”, but you would _never_ have a “Profile” in the absence of a “User”. In this type of situation, you want the “Profile” to have the OneToOneField referencing “User”.

---

<div class="post-metadata">

**Author:** ![shaiqahmad](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/shaiqahmad/32/18896_2.png) [@shaiqahmad](https://forum.djangoproject.com/u/shaiqahmad)\
**Post date:** [April 8, 2024, 7:16am UTC](https://forum.djangoproject.com/t/does-on-delete-models-cascade-applies-bidirectionally/29901/3 "2024-04-08T07:16:44Z")

</div>

Ok. Thank you KenWhitesell.
