Any alternatives for OneToMany or ManyToOne in Django

前端 未结 1 418
无人共我
无人共我 2021-01-21 10:15

I have a NOTIFICATION and an USER app in Django. The code goes something like :

class Notification(models.Model):
    user = mo         


        
相关标签:
1条回答
  • 2021-01-21 10:37

    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.

    0 讨论(0)
提交回复
热议问题