#28133: KeyError: u'blank' or KeyError: u'editable' when upgrading django
-------------------------------------+-------------------------------------
Reporter: latheef | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.8
Uncategorized | Keywords: upgrade django,
Severity: Normal | KeyError: u'blank', KeyError:
Triage Stage: | u'editable'
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/28133>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/055.470a82bfa71143e3093b312db4e670ff%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.