Re: Dictionary Model Merge

2010-02-16 Thread cootetom
Hi all, Thanks for every ones help on this. I have a fix now which is working well. from django.forms.models import model_to_dict values = model_to_dict(model_instance) for k, v in request.POST.copy().items(): values[k] = v form = FooForm(data = values, instance = model_instance)

Re: Dictionary Model Merge

2010-02-16 Thread pjrhar...@gmail.com
> values = model_to_dict(instance) > values.update(request.POST) > > It then fails on form.is_valid() because it's trying to match a date > string in a date value that is actually a list with one value in it > instead of a date string! I can see two problems here. Firstly, the post "dictionary"

Re: Dictionary Model Merge

2010-02-16 Thread cootetom
Have tried model.__dict__ and model_to_dict. In both cases it often returns values as objects instead of string values. For instance, a date comes back as a list, so does a text field. Then I'll receive an error like this: Environment: Request Method: POST Request URL:

Re: Dictionary Model Merge

2010-02-16 Thread Daniel Roseman
On Feb 15, 10:31 pm, cootetom wrote: > Thanks Javier but I'm having problems with that. I do want to create a > dictionary from the model first then override with the POST values. > But when I try to make a dictionary from the model I get an 'object is > not iterable' error.

Re: Dictionary Model Merge

2010-02-15 Thread Andy McKay
On 2010-02-15, at 2:31 PM, cootetom wrote: > Thanks Javier but I'm having problems with that. I do want to create a > dictionary from the model first then override with the POST values. > But when I try to make a dictionary from the model I get an 'object is > not iterable' error. Without the

Re: Dictionary Model Merge

2010-02-15 Thread cootetom
Thanks Javier but I'm having problems with that. I do want to create a dictionary from the model first then override with the POST values. But when I try to make a dictionary from the model I get an 'object is not iterable' error. On Feb 15, 9:41 pm, Javier Guerra wrote:

Re: Dictionary Model Merge

2010-02-15 Thread Javier Guerra
On Mon, Feb 15, 2010 at 4:27 PM, cootetom wrote: > I'm looking for something in the framework that I think must exist > somewhere but can't seem to find anything. I'm after a bit of code > that takes a dictionary (a.k.a the POST dictionary) and a model > instance, then merges

Dictionary Model Merge

2010-02-15 Thread cootetom
I'm looking for something in the framework that I think must exist somewhere but can't seem to find anything. I'm after a bit of code that takes a dictionary (a.k.a the POST dictionary) and a model instance, then merges the two into a new dictionary. The new dictionary then contains all values