#22289: Field with Validator always considered changed in migrations ----------------------------+--------------------------------------- Reporter: blueyed | Owner: nobody Type: Bug | Status: new Component: Migrations | Version: 1.7-alpha-2 Severity: Normal | Resolution: Keywords: | Triage Stage: Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 ----------------------------+---------------------------------------
Comment (by blueyed): The problem is that the deconstructor (`<bound method CharField.deconstruct of <django.db.models.fields.CharField: imdb_id>>`) returns different values/objects for the validators: {{{ ipdb> old_field_dec (u'django.db.models.CharField', [], {u'null': True, u'validators': [<django.core.validators.RegexValidator object at 0x1cac790>], u'max_length': 200, u'blank': True, u'help_text': u'IMDB ID (starts with "tt") or IMDB URL.', u'unique': True, u'verbose_name': 'IMDB ID'}) ipdb> new_field_dec (u'django.db.models.CharField', [], {u'null': True, u'validators': [<django.core.validators.RegexValidator object at 0x2cb5ad0>], u'max_length': 200, u'blank': True, u'help_text': <django.utils.functional.__proxy__ object at 0x2d872d0>, u'unique': True, u'verbose_name': 'IMDB ID'}) ipdb> l 334 new_model_state = self.to_state.models[app_label, model_name] 335 old_field_name = renamed_fields.get((app_label, model_name, field_name), field_name) 336 old_field_dec = old_model_state.get_field_by_name(old_field_name).deconstruct()[1:] 337 new_field_dec = new_model_state.get_field_by_name(field_name).deconstruct()[1:] 338 if old_field_dec != new_field_dec: 4-> 339 self.add_to_migration( 340 app_label, 341 operations.AlterField( 342 model_name=model_name, 343 name=field_name, 344 field=new_model_state.get_field_by_name(field_name), }}} I have noticed that there is `AlterField.__eq__`, which does never get called though?! {{{ def __eq__(self, other): return ( (self.__class__ == other.__class__) and (self.name == other.name) and (self.model_name.lower() == other.model_name.lower()) and (self.field.deconstruct()[1:] == other.field.deconstruct()[1:]) ) }}} -- Ticket URL: <https://code.djangoproject.com/ticket/22289#comment:5> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.b73c531b8fca69748ba5240e7351695d%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.