django admin LeafletGeoAdmin内联

时间:2015-10-01 23:51:01

标签: django django-admin leaflet

我想添加在管理员上添加多个图像的可能性,但我有困难,因为我使用LeafletGeo。

我在models.py

进行了更改
   class Logement(models.Model):
    titre = models.CharField(blank=True, max_length=100)
    grandeur = models.CharField(blank=True, max_length=30, choices=GRANDEUR)
    chauffe = models.BooleanField(default=False)
    eclaire = models.BooleanField(default=False)
    stationnement = models.CharField(blank=True, max_length=100, choices=STATIONNEMENT)
    pub_date = models.DateTimeField('date publication',default=datetime.now, blank=True)
    geom = PointField()

    class ImageLogement(models.Model):
        Logement     = models.ForeignKey('Logement', related_name="Logement")
        priorite = models.FloatField()
        picture = models.ImageField(upload_to = 'photos/', default = 'photos/Aucune/no-img.jpg')
        description = models.CharField(blank=True, max_length=100)

问题在于admin.py我丢失了LeafletGeoAdmin地图,当我想添加你可以在这里看到的最后两个课程时。

class LogementAdmin(LeafletGeoAdmin):
    list_display = ('titre', 'grandeur','chauffe','eclaire','stationnement')
    list_filter =('grandeur',)

class ImageLogementAdmin(admin.TabularInline):
    model = ImageLogement

class LogementAdmin(admin.ModelAdmin):
    model = Logement
    inlines = [ImageLogementAdmin,]

admin.site.register(Logement, LogementAdmin)

1 个答案:

答案 0 :(得分:1)

解决我的问题我删除

basic_ostream

我将class LogementAdmin(admin.ModelAdmin): model = Logement inlines = [ImageLogementAdmin,] 添加到inlines = [ImageLogementAdmin,]