Hi, try doing this:
c = Customer(**customerdict).save()
-- Scott
On Tue, Jul 1, 2008 at 12:56 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:
>
> I have an object called customer that I trying to initialize from a
> large XML parse. I parse the XML into a dictionary into something
> like
>
> customerdict = {'first_name' : 'mike', 'last_name' : 'c', 'etc' :
> 'etc' } and so forth
>
> then I try to do c = Customer(customerdict).save()
>
> I get a "Can't Adapt" error.
>
> However, if I manually pass in each variable like so:
>
> c = Customer(first_name = customerdict['first_name'], last_name =
> customerdict['last_name']).save()
>
> it works fine.
>
> Passing in each variable would be a huge PITA plus any changes to the
> model would require changes in multiple places while parsing and
> passing the dictionary wouldn't require any changes. What am I doing
> wrong?
>
> >
>
--
http://scott.andstuff.org/ | http://truthadorned.org/
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---