0
在models.py(admin.E301) 'app.model' 沒有GenericForeignKey
class Activities(models.Model):
day = models.PositiveIntegerField(default=1, null=False,blank=False,db_index=True)
activity = models.CharField(max_length=100, blank=False,choices=activity_choices, db_index=True)
description = models.TextField(null=True,blank=True)
sequence = models.PositiveIntegerField(null=True,blank=True)
class holidaygroup(models.Model):
....
activity = generic.GenericRelation(Activities)
在admin.py
class ActivitiesInline(generic.GenericTabularInline):
model = Activities
class holidaygroupAdmin(ReadOnlyAdminFields,admin.ModelAdmin):
....
inlines = [SeasonalPriceInline,ImageInline,HotelsInline,seoInline,NotesInline,ActivitiesInline,]
,當我試圖運行服務器得到了下面的錯誤
ERRORS:
<class 'holidays.admin.ActivitiesInline'>: (admin.E301) 'holidays.Activities' has no GenericForeignKey.
在此先感謝
Activities與HolidayGroup之間的關係是什麼?使用您當前的模型結構,您只能在活動中使用HolidayGroup內聯;反之亦然。 – Selcuk
我該如何糾正它?基本上我想活動作爲內聯節假日組 –
我試圖存儲假期組的對象下的許多活動。只是使用Foreginkey爲我工作?但我想從holidaygroup對象中獲取所有活動對象。 –