Error Reverse accessor for Analysis assign user clashes with reverse accessor for Inquiry assign user

0 votes

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

- Request
    - Inquiry
    - Analysis

Request has two foreign keys to the built-in User model.

create_user = models.ForeignKey(User, related_name='requests_created')
assign_user = models.ForeignKey(User, related_name='requests_assigned')

For some reason I'm getting the error

Reverse accessor for 'Analysis.assign_user' clashes with reverse accessor for 'Inquiry.assign_user'.

Everything I've read says that setting the related_name should prevent the clash, but I'm still getting the same error. Can anyone help me out why this would be happening? 

Jun 30, 2020 in Python by kartik
• 37,530 points

1 answer to this question.

0 votes

Hello @kartik,

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')

Hope this is helpful!

Thank you!

answered Jun 30, 2020 by Niroj
• 82,820 points

Related Questions In Python

+1 vote
10 answers

How to fix this? ValueError: invalid literal for int() with base 10 error in Python

Just for the record: >>> int('55063.000000') Traceback (most recent ...READ MORE

answered Aug 17, 2020 in Python by pakainfo
• 200 points
0 votes
0 answers

Size is (121,512,512). Error is coming as : IndexError: index 152 is out of bounds for axis 0 with size 121.

def nodule_detect(nodules,j,numpyImage, numpyOrigin, numpySpacing): ...READ MORE

Jan 28, 2020 in Python by anonymous
• 150 points
0 votes
1 answer

Error is "invalid literal for int() with base 10: ' ' "

This error is caused because we try ...READ MORE

answered Oct 15, 2020 in Python by Gitika
• 65,950 points
0 votes
1 answer

How to temporarily disable a foreign key constraint in MySQL?

Hello @kartik, To turn off foreign key constraint ...READ MORE

answered Jun 23, 2020 in Python by Niroj
• 82,820 points
0 votes
1 answer

How do I use Django templates without the rest of Django?

Hello @kartik, Let's say you have this important ...READ MORE

answered Jun 23, 2020 in Python by Niroj
• 82,820 points
0 votes
2 answers