Django: reverse accessors for foreign keys clashing

前端 未结 1 1489
醉话见心
醉话见心 2020-12-12 17:45

I have two Django models which inherit from a base class:

- Request
    - Inquiry
    - Analysis

Request has two foreign keys to the built-

相关标签:
1条回答
  • 2020-12-12 18:17

    The related_name would ensure that the fields were not conflicting with each other, but you have two models, each of which has both of those fields. You need to put the name of the concrete model in each one, which you can do with some special string substitution:

     create_user = models.ForeignKey(User, related_name='%(class)s_requests_created')
    
    0 讨论(0)
提交回复
热议问题