I wrote a clean_csi() method and I call it in each clean_<fieldname>()
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 Tredinnick <[email protected]> wrote:
> 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_<fieldname>()
> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---