0

Initially I created a model as shown here:

class MyModel(models.Model):
    creator = models.ForeignKey(User, on_delete=models.CASCADE, related_name="creater")
    # rest of the fields below

Notice, creator as a field with ForeignKey relation with related_name as creater which is actually a spelling mistake which I made. Then I ran python manage.py makemigrations and python manage.py migrate commands and it went well.

After that I realised that I need to correct the spelling and I changed it accordingly as shown here:

class MyModel(models.Model):
    creator = models.ForeignKey(User, on_delete=models.CASCADE, related_name="creator")
    # rest of the fields below

Now again to incorporate these changes I ran the above two command but when I ran python manage.py makemigrations command I got following error:

(django_env) dayanandghelaro@A006-00592 fiverr_backend % python manage.py makemigrations
SystemCheckError: System check identified some issues:

ERRORS:
gigs.Gig.creator: (fields.E304) Reverse accessor for 'gigs.Gig.creator' clashes with reverse accessor for 'orders.Order.creator'.
    HINT: Add or change a related_name argument to the definition for 'gigs.Gig.creator' or 'orders.Order.creator'.
gigs.Gig.creator: (fields.E305) Reverse query name for 'gigs.Gig.creator' clashes with reverse query name for 'orders.Order.creator'.
    HINT: Add or change a related_name argument to the definition for 'gigs.Gig.creator' or 'orders.Order.creator'.
orders.Order.creator: (fields.E304) Reverse accessor for 'orders.Order.creator' clashes with reverse accessor for 'gigs.Gig.creator'.
    HINT: Add or change a related_name argument to the definition for 'orders.Order.creator' or 'gigs.Gig.creator'.
orders.Order.creator: (fields.E305) Reverse query name for 'orders.Order.creator' clashes with reverse query name for 'gigs.Gig.creator'.
    HINT: Add or change a related_name argument to the definition for 'orders.Order.creator' or 'gigs.Gig.creator'.
(django_env) dayanandghelaro@A006-00592 fiverr_backend % 

If you want to see error in image then click here

Dayanand
  • 1
  • 3
  • [This](https://stackoverflow.com/questions/2606194/django-error-message-add-a-related-name-argument-to-the-definition/2607848) might be helpful – Rustam Garayev Sep 03 '21 at 07:29
  • Your `Gig` model also uses `creator` as a related name for user. Try to change them to `created_orders` and `created_gigs` so you can access them from users like `user.created_orders.all()` and `user.created_gigs.all()` respectively – Brian Destura Sep 03 '21 at 07:31
  • Dear @Rustam, I am sorry images was not attached properly so I edited the whole text here and formatted accordingly. Can you please tell me how to get it fixed now? – Dayanand Sep 03 '21 at 07:50

0 Answers0