我想知道如何更改由Django Admin創建的下拉列表的標籤。 以下兩個型號:Django管理員更改下拉標籤
class Media(models.Model):
race = models.ForeignKey(Race, verbose_name = _('race'), blank=True, null=True)
caption = models.CharField(verbose_name=_('caption'), max_length=255, blank=True, null=True)
credit = models.CharField(verbose_name=_('credit'), max_length=255, blank=True, null=True)
image = FileBrowseField("Image", max_length=200)
# Meta
date_updated = models.DateTimeField(auto_now=True, auto_now_add=True, verbose_name=_('date updated'))
date_added = models.DateTimeField(auto_now=False, auto_now_add=True, verbose_name=_('date added'))
class Race(models.Model):
category = models.ForeignKey(Category, verbose_name = _('category'))
name = models.CharField(max_length=255, verbose_name=_('name'))
slug = models.SlugField(max_length = 128, help_text = _('Automatic generated. Do not edit!'))
state = models.CharField(max_length=255, verbose_name=_('state'), blank=True, null=True)
city = models.CharField(max_length=255, verbose_name=_('city'), blank=True, null=True)
description = models.TextField(verbose_name=_('description'), blank=True, null=True)
banner = models.FileField(max_length = 255, upload_to = '_static/img/races/', verbose_name = _('banner'), blank=True, null=True)
title = models.FileField(max_length = 255, upload_to = '_static/img/races/', verbose_name = _('title'), blank=True, null=True)
bigbox = models.FileField(max_length = 255, upload_to = '_static/img/races/', verbose_name = _('big box'))
midbox = models.FileField(max_length = 255, upload_to = '_static/img/races/', verbose_name = _('medium box'), blank=True, null=True)
smallbox = models.FileField(max_length = 255, upload_to = '_static/img/races/', verbose_name = _('small box'), blank=True, null=True)
course = models.FileField(max_length = 255, upload_to = '_static/img/races/', verbose_name = _('course'), blank=True, null=True)
rules = models.CharField(max_length=255, blank=True, verbose_name=_('rules'))
results = models.CharField(max_length=255, blank=True, verbose_name=_('results'))
date = models.DateTimeField(auto_now=False, auto_now_add=False, verbose_name=_('date'), blank=True, null=True)
active = models.BooleanField(default=True)
# Meta
date_updated = models.DateTimeField(auto_now=True, auto_now_add=True, verbose_name=_('date updated'))
date_added = models.DateTimeField(auto_now=False, auto_now_add=True, verbose_name=_('date added'))
我需要的是這樣的:
下拉添加新媒體時選擇的種族應該展現的不僅是比賽的名字,但DATE_ADDED以及比賽。
任何幫助或方向將不勝感激。
謝謝!
無法在Race模型上定義__str__/__unicode__? – 2014-09-03 15:57:31
路易斯,它被定義,但我需要它只是賽名。我唯一需要的名稱和時間戳是在頁面上添加新媒體。 – 2014-09-03 17:44:12