ModelForm save call with data and instance
def view(request)
form = MyForm(request.POST, instance = MyModel(myfiled = 1))
if form.is_valid():
obj = form.save()
but POST will NEVER merged with instance i've looked through stack:
ModelForm's save() https://code.djangoproject.com/browser/django/trunk/django/forms/models.py#L362
save calls:
return save_instance(self, self.instance, self._meta.fields,
fail_message, commit, >>>
construct=False <<<)
BUT construct=False and in save_instance
https://code.djangoproject.com/browser/django/trunk/django/forms/models.py#L68
if construct:
instance = construct_instance(form, instance, fields,
exclude)
in doesn't populate instance with cleaned data
Bug or Feature?
and if it's feature, how can I set values dynamically if it's not
specified in POST
--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home