0

Every thing was working fine with Django1.6, but when upgraded to Django1.7 it showed "App registry not ready", so I changed get_user_model() to settings.AUTH_USER_MODEL in my models.

class MyModel(models.Model, SomeMixin):
    content = models.TextField()
    posted_by = models.ForeignKey(settings.AUTH_USER_MODEL,
                              related_name='name1')
    note = models.ForeignKey(SomeModel, related_name='name2')

    created = models.DateTimeField(auto_now_add=True)

Now, on starting the server I get following error messages.

ERRORS: apps.MyModel.posted_by: (fields.E304) Reverse accessor for 'model_field' clashes with reverse accessor for 'model_field'. HINT: Add or change a related_name argument to the definition for 'model_field' or 'model_field'.

Changing related is not the best way I can go for, as changing related name involves change to a lot of code. What am I missing here? What should be I looking for? Any help would be highly appreciated.

Uzhare
  • 1
  • 2
  • If the related names clash, then you can't really do anything except add or change `related_name`, even if that involves changing a lot of code. It's not clear what the clash is, because your question is a mixture of actual model names e.g. `Comment` and made-up names like `MyModel`. – Alasdair May 14 '14 at 08:57
  • This is just an example of one of my models and I get the same error for most of the models. I tried to change related names and that seem to fix the issue except for User.groups(which I cannot change). Any work arounds you suggest? – Uzhare May 14 '14 at 09:08
  • As I said before, I don't think your example code gives enough information to see what the problem is. Hope you figure it out. – Alasdair May 14 '14 at 11:24

1 Answers1

0

Setting related_name='+' for one of the fields solved a similar issue for me. See the comments to the accept answer on this question

Community
  • 1
  • 1
nu everest
  • 9,589
  • 12
  • 71
  • 90