Модели:
class Criterias(models.Model): name = ... class Places(models.Model): name = ... class PlacesToCriterias(models.Model): content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) object_id = models.PositiveIntegerField() content_object = GenericForeignKey() criteria_group = models.ForeignKey(Criterias)
Админка - Места:
class PlaceCriteriasInlineAdmin(GenericTabularInline): model = PlacesToCriterias class PlacesAdmin(admin.ModelAdmin): inlines = [PlaceCriteriasInlineAdmin] admin.site.register(Places, PlacesAdmin)
Админка - Критерии:
class CriteriaPlacesInlineAdmin(GenericTabularInline): model = PlacesToCriterias class CriteriasAdmin(admin.ModelAdmin): inlines = [CriteriaPlacesInlineAdmin] admin.site.register(Criterias, CriteriasAdmin)
Как получить список мест на странице критерия?