Is there a way to make 'GeoData' display inline in admin for 'Shop' and 'Park' objects?
(One Shop/Park can contain several locations)
# 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()
I tried many options from google, but none of them worked.
Thanks.
Try adding to your admin.py for those classes. Try something like this.
class ShopAdmin(admin.ModelAdmin):
list_display = ('tel', 'address', 'position')
This can be found in detail in the Djangobook admin chapter.
http://www.djangobook.com/en/2.0/chapter06.html
Dig you try filter_horizontal: http://www.djangobook.com/en/2.0/chapter06.html ?
It only works with ManyToManyFields, so you have to change your models.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.