0
Django的1.10外鍵使遷移
我只是想以統一的公共領域中的一般模型,然後從它繼承。我不知道我還能如何堅持DRY原則。但我無法進行遷移。你能在這裏給我一個建議嗎?
class GeneralModel(models.Model):
created_by = models.ForeignKey(User, on_delete=models.CASCADE, related_name="created_by")
class Meta:
abstract = True
class Image(GeneralModel):
...
class Masterphoto(GeneralModel):
...
回溯
python manage.py makemigrations
SystemCheckError: System check identified some issues:
ERRORS:
image.Image.created_by: (fields.E304) Reverse accessor for 'Image.created_by' clashes with reverse accessor for 'Masterphoto.created_by'.
HINT: Add or change a related_name argument to the definition for 'Image.created_by' or 'Masterphoto.created_by'.
image.Image.created_by: (fields.E305) Reverse query name for 'Image.created_by' clashes with reverse query name for 'Masterphoto.created_by'.
HINT: Add or change a related_name argument to the definition for 'Image.created_by' or 'Masterphoto.created_by'.
masterphoto.Masterphoto.created_by: (fields.E304) Reverse accessor for 'Masterphoto.created_by' clashes with reverse accessor for 'Image.created_by'.
HINT: Add or change a related_name argument to the definition for 'Masterphoto.created_by' or 'Image.created_by'.
masterphoto.Masterphoto.created_by: (fields.E305) Reverse query name for 'Masterphoto.created_by' clashes with reverse query name for 'Image.created_by'.
HINT: Add or change a related_name argument to the definition for 'Masterphoto.created_by' or 'Image.created_by'.
非常感謝。這正是我需要的。 – Michael