Blog.objects.filter(entry__headline__contains='Lennon').filter(entry__pub_date__year=2008)
queryset = Artist.objects.select_related(
'songs', 'fans'
).filter(songs__title__icontains='love', fans__votes_casted__gte=100)
from django.db import models
class Artist(models.Model):
name = models.CharField(max_length=60)
year_established = models.SmallIntegerField()
votes = models.IntegerField(blank=True, null=True)
class Song(models.Model):
artist = models.ForeignKey(Artist, related_name='songs')
title = models.CharField(max_length=5)
votes = models.IntegerField()
class Fan(models.Model):
artist = models.ForeignKey(Artist, related_name='fans')
name = models.CharField(max_length=5)
votes_casted = models.IntegerField()
class EventsMeetinglocation(models.Model):
id = models.IntegerField(primary_key=True)
name = models.CharField(max_length=100)
address = models.CharField(max_length=200)
class Meta:
managed = True
db_table = 'events_meetinglocation'
class EventsBoardmeeting(models.Model):
id = models.IntegerField(primary_key=True)
date = models.DateTimeField()
agenda_id = models.IntegerField(blank=True, null=True)
location_id = models.ForeignKey(EventsMeetinglocation)
minutes_id = models.IntegerField(blank=True, null=True)
class Meta:
managed = True
db_table = 'events_boardmeeting'
def meetings(request):
meetingData = EventsBoardmeeting.objects.all()
return render(request, 'board/meetings.html', {'data': meetingData })
{% for x in data %}
{{ x.location_id.name }}
{% endfor %}