Thanks guys.
-- On 1 March 2012 00:30, Mario Gudelj <mario.gudelj@gmail.com> wrote:
Hi djangoers,I've ran into an issue I'm not sure how to handle.I have a form with 7 checkboxes representing 7 days of the week. I want to collect the submitted days and use them in rrule to generate some dates.The form field looks like this:weekly_interval = forms.MultipleChoiceField(label='Repeat on:', choices=EventSeries.weekly_interval,widget=forms.CheckboxSelectMultiple, required=False)The choices are generated from this:weekly_interval = ((rrule.SU, 'Sun'),(rrule.MO, 'Mon'),(rrule.TU, 'Tue'),(rrule.WE, 'Wed'),(rrule.TH, 'Thu'),(rrule.FR, 'Fri'),(rrule.SA, 'Sat'))So, the form renders and everything is fine, but once I submit the form, the data is in incorrect format and I'm not sure how to fix it.This is how I'm collecting the interval:interval=form.cleaned_data['weekly_interval']Then I'm using it in this line:start_dates = list(rrule.rrule(rrule.WEEKLY, count=self.recurrences, byweekday=self.interval, dtstart=self.start_datetime))My problem is in this byweekday=self.intervalIf I test this form console with the following it works finestart_dates = list(rrule.rrule(rrule.WEEKLY, count=a_s.recurrences, byweekday=(rrule.MO,rrule.TU), dtstart=appt.start_time))But when I look at the interval submitted from the form using pdb it looks like this [u'WE', u'TH', u'SA']I suspect that I need to convert this from unicode to objects. Does anyone know the best approach? And what it would be?Thanks a million!-m
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment