[Python] reverse accessor model clashing Django Web App

Discussão em 'Python' iniciado por Stack, Maio 30, 2025.

  1. Stack

    Stack Membro Participativo

    from django.db import models
    from django.contrib.auth.models import AbstractUser


    class Customer(AbstractUser):
    address_line = models.CharField(max_length=255)
    city = models.CharField(max_length=255)
    postal_code = models.CharField(max_length=10)
    phone_number = models.CharField(max_length=20)
    origin_country = models.CharField(max_length=255)
    profile_picture = models.ImageField(upload_to='customer_profile_pics', null=True, blank=True)


    class Chef(AbstractUser):
    address_line = models.CharField(max_length=255)
    city = models.CharField(max_length=255)
    postal_code = models.CharField(max_length=10)
    phone_number = models.CharField(max_length=20)
    origin_country = models.CharField(max_length=255)
    profile_picture = models.ImageField(upload_to='chef_profile_pics', null=True, blank=True)


    class Meal(models.Model):
    name = models.CharField(max_length=255)
    description = models.TextField()
    picture = models.ImageField(upload_to='meal_pics')
    country = models.CharField(max_length=255)
    chef = models.ForeignKey(Chef, on_delete=models.CASCADE, related_name='meals')
    customers = models.ManyToManyField(Customer, blank=True, related_name='meals')


    class Discussion(models.Model):
    message = models.TextField()
    timestamp = models.DateTimeField(auto_now_add=True)
    customer = models.ForeignKey(Customer, on_delete=models.CASCADE, null=True, blank=True, related_name='discussions')
    chef = models.ForeignKey(Chef, on_delete=models.CASCADE, null=True, blank=True, related_name='discussions')



    This is my models.py file I get the following error while making migrations

    SystemCheckError: System check identified some issues:

    ERRORS:
    meals.Chef.groups: (fields.E304) Reverse accessor for 'Chef.groups' clashes with reverse accessor for 'Customer.groups'.
    HINT: Add or change a related_name argument to the definition for 'Chef.groups' or 'Customer.groups'.
    meals.Chef.user_permissions: (fields.E304) Reverse accessor for 'Chef.user_permissions' clashes with reverse accessor for 'Customer.user_permissions'.
    HINT: Add or change a related_name argument to the definition for 'Chef.user_permissions' or 'Customer.user_permissions'.
    meals.Customer.groups: (fields.E304) Reverse accessor for 'Customer.groups' clashes with reverse accessor for 'Chef.groups'.
    HINT: Add or change a related_name argument to the definition for 'Customer.groups' or 'Chef.groups'.
    meals.Customer.user_permissions: (fields.E304) Reverse accessor for 'Customer.user_permissions' clashes with reverse accessor for 'Chef.user_permissions'.
    HINT: Add or change a related_name argument to the definition for 'Customer.user_permissions' or 'Chef.user_permissions'.


    I tried some solutions on the internet but it didn't work, i want to test the app on my browser but making the migrations keeps showing me this error, please help!!!!

    I am really new to Django Back End Dev, I tried to troubleshoot the issue but i couldn't.

    Continue reading...

Compartilhe esta Página