On Mar 27, 4:34 pm, Thierry Chich <thierry.ch...@gmail.com> wrote: > I think I get the point. > > If I write > obj=MyModel() > obj.domaine=request.session.get("domaine") > form=MyModelForm(instance=obj) > if form.is_valid(): > form.save() > > It works (but I didn't populate my form) > So it seems that the data provided in data=request.POST are overwriting my > domaine field. > It is really curious, because request.POST doesn't contain any reference to my > field domaine > > It's look like a bug, isn't it ?
No, this is expected and documented behaviour. If the POST doesn't contain a value for a particular model field, that field is set to blank. This is because an empty HTML field is not included in an POST, exactly as if the field wasn't on the form at all. If you don't want this to happen, exclude the domaine field from the form altogether via the modelform Meta 'fields' or 'exclude' tuples. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.