我有一个场地,这个场地上发生了很多事件。我的模型如下所示:
class Event(models.Model):
title = models.CharField(max_length=200)
date_published = models.DateTimeField('published date',default=datetime.now, blank=True)
date_start = models.DateTimeField('start date')
date_end = models.DateTimeField('end date')
def __unicode__(self):
return self.title
description = models.TextField()
price = models.IntegerField(null=True, blank=True)
venue = models.ForeignKey(Venue)
class Venue(models.Model):
title = models.CharField(max_length=200)
date_published = models.DateTimeField('published date',default=datetime.now, blank=True)
venue_latitude = models.CharField(max_length=200)
venue_longitude = models.CharField(max_length=200)
venue_address = models.CharField(max_length=200)
venue_city = models.CharField(max_length=200)
venue_state = models.CharField(max_length=200)
venue_country = models.CharField(max_length=200)
description = models.TextField()
def __unicode__(self):
return u'%s' % (self.title)
我想显示在某个场所发生的所有事件。我怎样才能做到这一点?我当前的视图如下所示:
def detail(request, venue_id):
venue = get_object_or_404(Venue, pk=venue_id)
return render(request, 'venue-detail.html', {'venue': venue})