hdknr / annotated-django

Django for Study
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

admin: <class 'sample.admin.StatusPermInline'>: (admin.E202) 'sample.StatusPerm' has more than one ForeignKey to 'sample.Status'. #48

Closed hdknr closed 6 years ago

hdknr commented 6 years ago

models.py:

class StatusPerm(models.Model):
    status = models.ForeignKey(
        Status, related_name='perm_set', on_delete=models.CASCADE)
    status_from = models.ForeignKey(
        Status, related_name='permfrom_set', on_delete=models.CASCADE,
        null=True, blank=True, default=None)
    perm = models.ForeignKey(
        Permission, on_delete=models.CASCADE, )

admin.py:

class StatusPermInline(admin.TabularInline):
    model = models.StatusPerm
    exclude = []
    extra = 0
hdknr commented 6 years ago

fk_name を定義する


class StatusPermInline(admin.TabularInline):
    model = models.StatusPerm
    exclude = []
    extra = 0
    fk_name = 'status'