Re: How-to use SelectMultiple widget with CommaSeparatedIntegerField ?
I wrote a clean_csi() method and I call it in each clean_() method passing the field name and and it's working now Here is the code def clean_csi(self, field): data = self.cleaned_data[field] data.sort() csi_list = [] first_element = True for element in data: if not first_element: csi_list.append(",") else: first_element = False csi_list.append(str(element)) return "".join(csi_list) def clean_hour(self): return self.clean_csi('hour') Thank you for your help ! On 7 août, 03:52, Malcolm Tredinnickwrote: > On Thu, 2009-08-06 at 07:35 -0700, nono wrote: > > I was reading my post and though it was not very clear > > > My model uses CommaSeparatedIntegerField to store some integer values. > > I want my users to use SelectMultiple widget to create/update those > > integer so I put a ChoiceField with widget=SelectMultiple in my form. > > My problem is that all I can get from this is a list of values (for > > example [u'2', u'3']) where I expect comma separated values ("2, 3"). > > > I hope this is a better explanation and somebody could help me > > If you want to normalise the values that are submitted to something > other than what happens automatically, write a clean_() > method for that form field. Have a look at > > http://docs.djangoproject.com/en/dev/ref/forms/validation/ > > for details. > > Regards, > Malcolm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: How-to use SelectMultiple widget with CommaSeparatedIntegerField ?
On Thu, 2009-08-06 at 07:35 -0700, nono wrote: > I was reading my post and though it was not very clear > > My model uses CommaSeparatedIntegerField to store some integer values. > I want my users to use SelectMultiple widget to create/update those > integer so I put a ChoiceField with widget=SelectMultiple in my form. > My problem is that all I can get from this is a list of values (for > example [u'2', u'3']) where I expect comma separated values ("2, 3"). > > I hope this is a better explanation and somebody could help me If you want to normalise the values that are submitted to something other than what happens automatically, write a clean_() method for that form field. Have a look at http://docs.djangoproject.com/en/dev/ref/forms/validation/ for details. Regards, Malcolm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: How-to use SelectMultiple widget with CommaSeparatedIntegerField ?
I was reading my post and though it was not very clear My model uses CommaSeparatedIntegerField to store some integer values. I want my users to use SelectMultiple widget to create/update those integer so I put a ChoiceField with widget=SelectMultiple in my form. My problem is that all I can get from this is a list of values (for example [u'2', u'3']) where I expect comma separated values ("2, 3"). I hope this is a better explanation and somebody could help me On 6 août, 14:21, nonowrote: > Hi, > > my model uses CommaSeparatedIntegerField to store a list of integer. I > want my users to use SelectMultiple widget to create/update this field > so I put a ChoiceField with widget=SelectMultiple in my form. My > problem is that all I can get from this is a list of values where I > expect comma separated values. > Do you have a solution for me ? > > regards --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
How-to use SelectMultiple widget with CommaSeparatedIntegerField ?
Hi, my model uses CommaSeparatedIntegerField to store a list of integer. I want my users to use SelectMultiple widget to create/update this field so I put a ChoiceField with widget=SelectMultiple in my form. My problem is that all I can get from this is a list of values where I expect comma separated values. Do you have a solution for me ? regards --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---