﻿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
28133	KeyError: u'blank' or KeyError: u'editable' when upgrading django	latheef	nobody	"Seems this error is oftenly coming when doing `makemigrations` or `migrate` commad.

In django 1.8, line is

https://github.com/django/django/blob/1.8/django/db/models/fields/__init__.py#L1252


{{{
        if self.auto_now or self.auto_now_add:
            del kwargs['editable']
            del kwargs['blank']
}}}

This is not checking whether field is there or not. Can solve it by
{{{
        if self.auto_now or self.auto_now_add:
            if 'editable' in kwargs: del kwargs['editable']
            if 'blank' in kwargs: del kwargs['blank']
}}}

After some digging I can see the problem is happening because of `deconstruct` method in `Field` class.

The place where above `kwargs` getting is


{{{
        keywords = {}
        possibles = {
            ""verbose_name"": None,
            ""primary_key"": False,
            ""max_length"": None,
            ""unique"": False,
            ""blank"": False,
            ""null"": False,
            ""db_index"": False,
            ""default"": NOT_PROVIDED,
            ""editable"": True,
            ""serialize"": True,
            ""unique_for_date"": None,
            ""unique_for_month"": None,
            ""unique_for_year"": None,
            ""choices"": [],
            ""help_text"": '',
            ""db_column"": None,
            ""db_tablespace"": settings.DEFAULT_INDEX_TABLESPACE,
            ""auto_created"": False,
            ""validators"": [],
            ""error_messages"": None,
        }
        attr_overrides = {
            ""unique"": ""_unique"",
            ""choices"": ""_choices"",
            ""error_messages"": ""_error_messages"",
            ""validators"": ""_validators"",
            ""verbose_name"": ""_verbose_name"",
        }
        equals_comparison = {""choices"", ""validators"", ""db_tablespace""}
        for name, default in possibles.items():
            value = getattr(self, attr_overrides.get(name, name))
            # Unroll anything iterable for choices into a concrete list
            if name == ""choices"" and isinstance(value, collections.Iterable):
                value = list(value)
            # Do correct kind of comparison
            if name in equals_comparison:
                if value != default:
                    keywords[name] = value
            else:
                if value is not default:
                    keywords[name] = value
}}}
Here, it is not returning keys `editable` or `blank` sometimes based on if condition.Thats why it is happening."	Bug	closed	Migrations	1.8	Normal	invalid	upgrade django, KeyError: u'blank', KeyError: u'editable'		Unreviewed	0	0	0	0	0	0
