for the last couple of hours, I´ve read all entries about custom  
manipulators but I´m still not able to get my stuff working.
I probably just don´t see what´s wrong anymore:

this is part of my MODEL:

class UserProfile(models.Model):
     music = models.ManyToManyField(Music, blank=True, null=True,  
related_name="music")
     ....


this is part of my CUSTOM MANIPULATOR:

class UserprofileManipulator(forms.Manipulator):
     def __init__(self):
         MUSIC_CHOICES = [(str(c.id), str(c)) for c in  
Music.objects.all()]
         self.fields = (
             forms.CheckboxSelectMultipleField(field_name="music",  
choices=MUSIC_CHOICES),
            ...
         )
     def save(self, data):
         temp = UserProfile(
                ...
         )
         temp.set_gadgets(data['gadgets'])
         temp.save()
        #temp.gadgets = Gadgets.objects.filter(id__in=data.getlist('gadgets'))


in the VIEW:

manipulator = UserprofileManipulator()
user_profile_manipulator = UserProfile.ChangeManipulator 
(request.user.id)
user_profile = user_profile_manipulator.original_object
if request.POST:
        new_data = request.POST.copy()
         errors = manipulator.get_validation_errors(new_data)
         if not errors:
                manipulator.do_html2python(new_data)
                 manipulator.save(new_data)
else:
        errors = {}
         new_data = user_profile_manipulator.flatten_data()
        ...


PROBLEMS:
1. the m2m-relationship doesn´t get saved.
2. in the template i have to write {{ form.gadgets_id }} to output  
the checkboxes ... instead of {{ form.gadgets }}

thanks,
patrick









--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to