1👍
✅
Assuming state
derives from post
you should be using filter
instead of get
and iterate stateme
in your template, e.g.
def home(request, finhall_id, slug):
qs = Finhall.objects.all()
try:
finhall = qs.get(id=finhall_id, slug=slug)
except Finhall.DoesNotExist:
finhall = None
if finhall:
similar_finhalls = qs.filter(finhall.state)
else:
similar_finhalls = Finhall.objects.none()
# other stuff
return render_to_response('home.html', {
'finhall': finhall,
'similar_finhalls': similar_finhalls
},context_instance=RequestContext(request))
Source:stackexchange.com