i have the following model:
gpstimeanddate = models.DateTimeField(db_column='GPSTimeAndDate') # Field name made lowercase.
from .models import Basestationreport
fromdate = request.POST.get('from')
todate = request.POST.get('to')
result = Basestationreport.objects.filter(gpstimeanddate > datetime.date(2005, 1, 1))
return HttpResponse(json.dumps(request.POST), content_type="application/json")
NameError: name 'gpstimeanddate' is not defined.
The error is because its looking for a local variable called
gpstimeanddate which you obviously haven't defined, nor are trying to use.
Since you're trying to use it as a field to filter results on you need to use it as a keyword in fiter, as well as use
.filter(gpstimeanddate__gt=datetime.date(2005, 1, 1))