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