Skip to content Skip to sidebar Skip to footer

Any Alternatives For Onetomany Or Manytoone In Django

I have a NOTIFICATION and an USER app in Django. The code goes something like : class Notification(models.Model): user = models.ForeignKey(User , related_name = 'notification'

Solution 1:

OneToManyField doesn't exist in Django because it is just the reverse relationship of a ForeignKey. So you don't need the notifications field on the User model here, just remove it.

Don't worry prematurely about performance of filtering on the notifications. Querying relations is what SQL was designed for, and that's what relational databases are good at doing.

Post a Comment for "Any Alternatives For Onetomany Or Manytoone In Django"