I'm trying to do something fairly simple. Allow a user to type in a text field the searchterm, and select the search field from a drop down box. But I seem to be getting the above error.
Template
<form method='post' action=''>
<input type='text' id='searchterm'>
<select id='searchfield'>
<option value='username'>Username</option>
<option value='status'>Status</option>
</select>
</form>
View
def existing(request):
if request.method == 'POST':
searchterm = request.POST['searchterm']
searchfield = request.POST['searchfield']
records = User.objects.filter(searchfield=searchterm)
else:
records = User.objects.all()
return render_to_response('gpon_table.html',locals())
Models
class User(models.Model):
username = models.CharField(max_length=50)
status = models.CharField(max_length=50)
Perhaps I am doing something wrong in the view.
Any help much appreciated.