Field instance copying failes before contribute_to_class
|Reported by:||paluh||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Python copy.copy() called on Field instance which is not contributed to class (before contribute_to_class call) raises:
AttributeError: 'SomeField' object has no attribute 'model'
This issue is related to #12977 changeset. It has added db.models.Field.__setstate__ method which expects that Field instance has 'model' attribute (but it is initialised in contribute_to_class method). I think that copying of instance should be safe all the time and this problem can be easily fixed by 'hasattr' check. Should I provide patch with test?