【发布时间】:2012-11-16 18:49:08
【问题描述】:
我想知道如何根据布尔值过滤下拉列表。假设其中一个对象是True,那么它会显示,但如果它是False,则不会显示。
任何帮助都会很棒。这是我的模型和管理文件的副本
models.py
class Airports(models.Model):
id = models.AutoField("ID", primary_key=True, editable=False,)
airporticao = models.CharField("Airport ICAO", max_length=6, help_text="Example: CYYZ or KLGA")
airportname = models.CharField("Airport name", max_length=50, help_text="Example:")
country = models.CharField("Country", max_length=50, help_text="Example: Canada")
hub = models.BooleanField("Hub?", default=False)
admin.py 用于配置文件模块:
class UserProfileadmin(admin.ModelAdmin):
list_display = ['user', 'country', 'vatsimid', 'totalflights', 'totalhours', 'hub']
search_fields = ['user']
【问题讨论】:
标签: python mysql django django-models django-admin