well, now I´m totally confused. I though that´s exactly what custom manipulators are here for: "You can easily create your own custom manipulators for handling custom forms." (django documentation).
more below ... Am 21.09.2006 um 22:47 schrieb Ivan Sagalaev: > > patrickk wrote: >> flatten_data() doesn´t relate to the custom manipulator but to model >> resp. the changemanipulator. > > I see now... And if I'm guessing correctly you're creating a > FormWrapper > from user_profile_manipulator that just doesn't have that checkbox > field. that´s right. user_profile_manipulator doesn´t have that checkbox field. in the model, the relation is defined as: music = models.ManyToManyField(Music, blank=True, null=True, related_name='music') at this point, there is nothing defined about *how* to display that relation (e.g. using checkboxes). > > Anyway making two manipulators is unnecessary and I can't even imagine > how is this supposed to work :-). as mentioned above, I thought that´s the primary use-case for custom manipulators: the custom manipulator handles the custom form the changemanipulator handles the data is that wrong? > > Now, if I understand your task you want a form for your user > profile but > with multiple checkboxes for 'music' field. Right? Then you can > inherit you manipulator from automatic > UserProfile.ChangeManipulator and > replace this field with what you need: > > class UserProfileManipulator(UserProfile.Manipulator): > def __init__(self, id): > UserProfile.Manipulator.__init__(self, id) > > # Finding and removing standard field > for field in self.fields: > if field.field_name == 'music': > self.fields.remove(field) > break > > # Adding custom field > MUSIC_CHOICES = [(str(c.id), str(c)) > for c in Music.objects.all()] > self.fields.append(forms.CheckboxSelectMultipleField( > 'music', > choices=MUSIC_CHOICES)) > > Does it make sense? some thoughts on that: 1. if I do it that way, I´m having checkboxes in the admin-interface, right? 2. is that the standard way to do it? it seems really complicated (ref. to finding and removing fields)? 3. instead of "finding and removing a field" - why not write a custom manipulator, add specific validation etc.? your suggestion might work, but (to me) it doesn´t seem like the "django way" to do that. thanks a lot for your help. gotta get some sleep, patrick > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

