> Basically, I  store the cleaned_data in the session for POSTs and use
> the cleaned_data in order to initialize a ModelForm for display after
> GETs.  Eventually, I have to save some things.  When that happens, I
> again get the data from a session:
>
>        for i in range(len(self.get_form_list(request.session))):
>            page_data = self._get_page_data(request.session, i)
>            form_class = form_list[i]
>            form = form_list[i](page_data)
>            form.save()
>
> At this point, though, I will have trouble with foreign keys again.
> Specifically, I have actual ForeignKey model objects in my data
> argument, and save throws a TypeError like so:
>
>    int() argument must be a string or a number, not 'MyModel'


Just for the record, I ended up with this:

     SomeModel(**page_data).save()

instead of the corresponding:

     SomeModelForm(page_data).save()

and that resolves the issue with foreign keys.  I guess ModelForm is
expecting ids instead of an actual model instance.

-Dave

--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to