﻿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
30756	ModelForm does not work well with the override field on Inherited Model	Ramon Soares	nobody	"Following the samples:

{{{
class City(models.Model):
    name = models.CharField(max_length=100)


class AddressBase(models.Model):
    city = models.ForeignKey(City, on_delete=models.PROTECT)
    ...
    country = models.ForeignKey(...)
    
    class Meta:
        abstract = True


class Address(AddressBase):
    city = models.CharField(max_length=100)


class AddessForm(forms.ModelForm):
    class Meta:
        model = Address
        fields = (""city"", )
}}}

I expect a rendered form with the city field as a CharField, but I got the following error: 

{{{ Cannot assign ""''"": ""Address.city"" must be a ""City"" instance. }}}

The problem, I think, is with the code above, on models.Field.contribute_to_class

{{{ 
        if self.column:
            # Don't override classmethods with the descriptor. This means that
            # if you have a classmethod and a field with the same name, then
            # such fields can't be deferred (we don't have a check for this).
            if not getattr(cls, self.attname, None):
                setattr(cls, self.attname, DeferredAttribute(self.attname))
}}"	Bug	closed	Database layer (models, ORM)	2.2	Normal	duplicate			Unreviewed	0	0	0	0	0	0
