[Django]-Django "Add a related_name argument to the definition" Error

3👍

The problem you are seeing is because of the ForeignKey and ManyToManyField fields in the BaseComment model. Because it is an abstract model, django does not create a table for it.

However, the derived models QuestionComment and AnswerComment which inherit the fields try to add the same fields defined by related_name (written_comments , voted_comments ) in the MyUser model. Because you can have only one field with the same name it gives you those errors.

A solution would be to not have BaseComment as an abstract model and let it have its own table/model.

Or, you could add these fields in derived models.

You can also try not specifying related_name and let django decide the names, but I’m not sure if this will work or not.

👤Rohan

Leave a comment