﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
15995	Problems in ModelForm._post_clean	Florian Apolloner	nobody	"Hi,

I have a model with the following field:
{{{
    author = models.ForeignKey(User, on_delete=models.PROTECT)
}}}
The related modelform sets this field to ''required = False''

This field should obviously pass form validation in the admin since ''required'' will be ''False''! But then in ''_post_clean'' of the modelform it tries to construct the instance: http://code.djangoproject.com/browser/django/trunk/django/forms/models.py#L308

which immediately fails cause author can't be ''None'': http://dpaste.com/540716/

Oddly enough, the code later on collects the fields for model validation: ''exclude = self._get_validation_exclusions()''. This code would add ''author'' to the ignore list: http://code.djangoproject.com/browser/django/trunk/django/forms/models.py#L288

So model validation would be happyily exclude my field from validation, but it already fails in construct_instance. I think ''_post_clean'' should use the calculated exclude list instead of ''opts.exclude'' for the ''construct_instance'' call"	Bug	closed	Forms	dev	Normal	duplicate			Accepted	0	0	0	0	0	0
