有没有办法让'GeoData'显示在'Shop'和'Park'对象的内联中?
(一个商店/公园可以包含多个地点)
# Location data
class GeoData(models.Model):
lat = models.FloatField()
lon = models.FloatField()
description = models.TextField()
# Parent class for every object with location data
class GeoEntity(models.Model):
title = models.CharField(max_length=32)
position = models.ForeignKey(GeoData)
class Shop(GeoEntity):
tel = models.CharField(max_length=32)
address = models.TextField()
class Park(GeoEntity):
wifi = models.BooleanField()
area = models.IntegerField()
我尝试了谷歌的很多选项,但都没有。
感谢。
答案 0 :(得分:0)
尝试为您的admin.py添加这些课程。尝试这样的事情。
class ShopAdmin(admin.ModelAdmin):
list_display = ('tel', 'address', 'position')
这可以在Djangobook管理章节中找到 http://www.djangobook.com/en/2.0/chapter06.html
答案 1 :(得分:-1)
你试试filter_horizontal:http://www.djangobook.com/en/2.0/chapter06.html?
它仅适用于ManyToManyFields,因此您必须更改模型。