Hello Derek, The grantstartdt field has a date format, the Year field (drop down) is a list of years in YYYY format, but the field is character. I need to parse the YYYY from the date field to match the YYYY of the Year value. When I changed the code as you suggested I received this error:
date/time field value out of range: "30-01-01 00:00:00" HINT: Perhaps you need a different "datestyle" setting. On May 29, 5:37 pm, Derek Willis <dwil...@gmail.com> wrote: > When you use grantstartdt__year in your filter, it's looking for an > integer, not an instance of your Year model, which is what you have in > your view. So, assuming the pk attribute in Year is an integer, you'd > change your line to something like this: > > projectyr=Researchproject.objects.exclude(activeyesno = 2).filter > (grantstartdt__year=yr.pk) > > Which should do the trick. Alternately you could use year_id if you > don't need your Year model for the template. > > Derek > > On May 29, 3:33 pm, Jesse <adles...@gmail.com> wrote: > > > Hello, > > > year_id (2004 etc) is a dropdown box on the template. The users > > selects a year and this is retrieved as year_id in the view. I need > > to select publications based on year from a field called grantstartdt > > which is in the format 2008-01-01. The error is: > > > int() argument must be a string or a number, not 'Year' > > > year_id = request.GET['year_id'] > > yr = get_object_or_404(Year, pk=year_id) > > projectyr=Researchproject.objects.exclude(activeyesno = 2).filter > > (grantstartdt__year=yr) > > > Thank you for any assistance! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---