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 GiordaniAuthor of The Digital Cat
My profile on About.me - My GitHub page - My Coderwall profile
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=RequestContex t(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!To view this discussion on the web visit https://groups.google.com/d/--
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 .msgid/django-users/4521ed83- .d85b-42a5-a344-27ac273648b9% 40googlegroups.com
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+unsubscribe@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.
No comments:
Post a Comment