我有这样的模特
class BaseRequest(models.Model):
created = models.DateTimeField(auto_now_add=True, editable=False)
modified = models.DateTimeField(auto_now=True, editable=False)
price_quoted = models.DecimalField(max_digits=10, decimal_places=2,null=True, blank=True)
class RequestLeg(models.Model):
created = models.DateTimeField(auto_now_add=True, editable=False)
modified = models.DateTimeField(auto_now=True, editable=False)
depart_date = models.DateField()
num_seats = models.IntegerField()
class Request(BaseRequest):
owner = models.ForeignKey(User, null=True, blank=True)
name = models.CharField(max_length=30, null=True, blank=True)
email = models.EmailField()
phone = models.CharField(max_length=30, null=True, blank=True)
legs = models.ManyToManyField(RequestLeg)
和上述请求模型的管理员是
class RequestAdmin(NoDeletionsAdmin):
list_display=['id', 'created', 'name', 'depart_date']
def depart_date(self, obj):
try:
return min([leg.depart_date for leg in obj.legs.all()])
except ValueError, e:
return None
我想在RequestAdmin中使用depart_date的Daterangelist过滤器?