I have a custom manipulator:

class Pircejs_Add(Manipulator):
        def __init__(self):
                self.fields = (
                        TextField(field_name='vards', is_required=True),
                        TextField(field_name='uzvards', is_required=True),
                        EmailField(field_name='email', is_required=False, 
length=30),
                        
TextField(field_name='mob_nr',is_required=True,length=8,maxlength=8,
validator_list=[check_mob,]),
                        
SelectField(field_name='mob_operators',is_required=True,choices=[(ch.id,ch)
for ch in Choice.objects.filter(group=0)]),
                        
SelectField(field_name='dzimums',is_required=True,choices=[(ch.id,ch)
for ch in Choice.objects.filter(group=1)]),
                        DateField(field_name='dz_datums',is_required=True),
                        
SelectField(field_name='gimenes_stavoklis',is_required=True,choices=[(ch.id,ch)
for ch in Choice.objects.filter(group=2)]),
                        
SelectField(field_name='ienakumi',is_required=True,choices=[(ch.id,ch)
for ch in Choice.objects.filter(group=3)]),
                        
SelectField(field_name='nodarbosanas',is_required=True,choices=[(ch.id,ch)
for ch in Choice.objects.filter(group=4)]),
                        
SelectField(field_name='adrese',is_required=True,choices=[(ch.id,ch)
for ch in Choice.objects.filter(group=5)]),
                        
SelectField(field_name='dzivesvieta',is_required=True,choices=[(ch.id,ch)
for ch in Choice.objects.filter(group=6)]),
                        
SelectField(field_name='parvietosanas',is_required=True,choices=[(ch.id,ch)
for ch in Choice.objects.filter(group=7)]),
                        PasswordField(field_name='password',
is_required=True,validator_list=[check_pass,]),
                        PasswordField(field_name='re_password', 
is_required=True),
                        CheckboxField(field_name='is_active'),
                        CheckboxField(field_name='blokets'),
                        SelectMultipleField(field_name='groups')
                )

        def save(self,new_data):
                u = User(**new_data)
                u.set_password(new_data['password'])
                u.save()
                return u

Django throws me an error: "Invalid value: 'mob_operators' should be a
instance, not a". Field mob_operators (mobile phone operator) is a
ForeignKey of some table. How I understand, django is waiting an
instance of mobile operators, but I give him a ID nummber. How can I
tell django, that this is the ID of the instance. For example, if I use
the default AddManipulator, then all works fine.

One of the solutions is to add smth like this:
u = User(
    first_name=new_data['firstname'],

mob_operators=Choices.objects.get(pk=int(new_data['mob_operators']))
.......
)

But this is not nice, I want solve this in django way :)


--~--~---------~--~----~------------~-------~--~----~
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