I have a model called Finhall
and fields under it. But in my view I want to get the value of state
field the user clicked on in order to filter other places in that same state. After trying this codes, I'm getting the below error:
global name 'finhall' is not defined
Models
class Finhall(models.Model):
user=models.ForeignKey(User)
name=models.CharField(max_length=250, unique=True)
address=models.CharField(max_length=200)
city=models.CharField(max_length=200)
state=models.CharField(max_length=200, help_text='Las vegas')
def __unicode__(self):
return u'%s' % (self.name)
Views
def homedetail(request,finhall_id,slug):
qs=Finhall.objects.all()
try:
post=qs.get(id=finhall_id,slug=slug)
except Finhall.DoesNotExist:
post=None
if post:
similar_posts=qs.filter(finhall.state) #this line is causing the error
else:
similar_posts=Finhall.objects.none()
return render_to_response('homedetail.html',{'post':post,'similar_posts':similar_posts},context_instance=RequestContext(request))
I've been trying to fix this error all day yet no success!