楷模:
class Event(models.Model):
place = models.ForeignKey(SomePlacesModel, on_delete = models.CASCADE)
event_name = models.CharField('Event Name', max_length = 20)
event_date= models.DateField('Event Date')
...
class Result(models.Model)
event = models.ForeignKey(Event, on_delete = models.CASCADE)
event_name = models.CharField('Event Name', max_length = 20) # Cache from Event
result = models.FloatField('Result')
some1 = ....
some2 = ....
我需要获取上个月(周等)按 Event.event_date 排序的结果查询集(但这不起作用..):
res = Result.objects.select_related('event__event_date').filter(some1 = something1, some2 = something2).order_by('event_name')[range:]
谢谢。
陪伴而非守候
相关分类