Are you sure that filtering using a string is the same as filtering using an int? I think that Django doesn't automatically convert it. So the condition
events = Event.objects.filter(end__month='11') should be events = Event.objects.filter(end__month=11) Indeed documentation<https://docs.djangoproject.com/en/dev/ref/models/querysets/#year>does things this way. I see that you succeded in filtering with filter(end_start='2013') perhaps end__startswith? In that case you are treating it as a string. May you please check this and let me know? Cheers, Leo Leonardo Giordani Author of The Digital Cat <http://lgiordani.github.com> My profile on About.me <http://about.me/leonardo.giordani> - My GitHub page<https://github.com/lgiordani>- My Coderwall profile <https://coderwall.com/lgiordani> 2013/11/26 Vojtěch Tranta <vojta.tra...@gmail.com> > from django.db import models > from django.contrib.auth.models import User > from student import Student > from eventtype import EventType > from django import forms > import datetime > > class Event(models.Model): > user = models.ForeignKey(User) > student = models.ForeignKey(Student) > place = models.CharField(max_length=200, null=True) > type = models.ForeignKey(EventType) > start = models.DateTimeField('event start', default=datetime.datetime.now) > end = models.DateTimeField('event end', default=datetime.datetime.now) > absence = models.NullBooleanField() > note = models.TextField(null=True) > created = models.DateTimeField('created time') > created_by = models.ForeignKey(User, related_name='event creator') > description = models.TextField(null=True) > > class Meta: > app_label = 'jvc' > > def __unicode__(self): > return self.type.name +' '+ self.student.fullname +' > '+self.start.strftime('%d.%m.%Y') > > I should mention that I have my models in separated files in "models" > folder inside app called "jvc" > > Dne úterý, 26. listopadu 2013 8:25:40 UTC+1 Leo napsal(a): >> >> May you please post your Event model? >> >> Leonardo Giordani >> Author of The Digital >> Cat<http://www.google.com/url?q=http%3A%2F%2Flgiordani.github.com&sa=D&sntz=1&usg=AFQjCNGf6sQVThK6cSl7xZSyl-Bug05qnQ> >> My profile on >> About.me<http://www.google.com/url?q=http%3A%2F%2Fabout.me%2Fleonardo.giordani&sa=D&sntz=1&usg=AFQjCNENNv2kLwQkkcUqNGwAk9LiXuqX-g>- >> My GitHub >> page<https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Flgiordani&sa=D&sntz=1&usg=AFQjCNEkP_q2HuIVZV_RDYFkz6AxG6GeqA>- >> My Coderwall >> profile<https://www.google.com/url?q=https%3A%2F%2Fcoderwall.com%2Flgiordani&sa=D&sntz=1&usg=AFQjCNHxgTeAYqzzxvSU2GFb7dMA1APtEA> >> >> >> 2013/11/26 Начаров Михаил <michael....@gmail.com> >> >>> Hi Tranta. >>> In my projects this functionality works fine. >>> What version of django did you used? >>> Do you sure that field end in Event table contains November dates? >>> >>> Also, you can use *today.month* instead of *int(today.strftime('%m')*) >>> and* today.year *instead of *int(today.strftime('%Y')).* >>> And in django docs says that it necessary to validate your form before >>> use it: >>> >>> *if event_form.is_valid():* >>> * event = event_form.save()* >>> >>> >>> вторник, 26 ноября 2013 г., 5:24:21 UTC+6 пользователь Vojtěch Tranta >>> написал: >>> >>>> Hi, >>>> do you have any clue why this does not work? >>>> >>>> def index(request): >>>> if request.method == 'POST' and request.POST: >>>> event_form = EventForm(request.POST) >>>> event = event_form.save() >>>> >>>> today = datetime.date.today(); >>>> year = int(today.strftime('%Y')) >>>> month = int(today.strftime('%m')) >>>> events = Event.objects.filter(end__month='11') >>>> # events = Event.objects.all() >>>> pdb.set_trace() >>>> cal = jvccalendar.HTMLCalendar(jvccalendar.MONDAY).formatmonth(year, >>>> month, events) >>>> form = EventForm() >>>> return render_to_response('jvc/index.html', {'cal': cal, 'side_form': >>>> form}, context_instance=RequestContext(request)) >>>> >>>> >>>> I am still getting "events" as empty, filtering using >>>> filter(end_start='2013') works, but filtering by month does not, I googled >>>> as much as I could, but no luck. I copied code from StackOverflow, but no >>>> luck.... >>>> Thank you! >>>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to django-users...@googlegroups.com. >>> To post to this group, send email to django...@googlegroups.com. >>> >>> Visit this group at http://groups.google.com/group/django-users. >>> To view this discussion on the web visit https://groups.google.com/d/ >>> msgid/django-users/4521ed83-d85b-42a5-a344-27ac273648b9% >>> 40googlegroups.com. >>> >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/5a50a517-fe4f-48b5-a713-c5042b5cab3b%40googlegroups.com > . > > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEhE%2BOm2eMP0YAgQEbUQj7rtAMjrQWV7nigUnbciBq1FfzfecA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.