#28073: RemoveField.state_forwards() crashes with AttributeError: 'NoneType'
object
has no attribute 'is_relation'
---------------------------------+------------------------------------
Reporter: Logan Gunthorpe | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Comment (by Python Force):
I cannot because it took me 2 days to find out what it was and now it is
fixed. Problem was that the migration with the missing field in the
database based on that function was coming empty and you calling a method
on that which is throwing an error.
As Logan said "Seeing as the comment above implies that old_field is None
or ... would be a valid solution I don't see why you wouldn't just put
that in."
I have explained everything above in details that is a simple project and
it happened precisely just like that. I am not sure how better I can
describe it. I am not sure why you have changed that migration function if
this one is working well...in 1.10.7.
{{{
def state_forwards(self, app_label, state):
new_fields = []
for name, instance in state.models[app_label,
self.model_name_lower].fields:
if name != self.name:
new_fields.append((name, instance))
state.models[app_label, self.model_name_lower].fields = new_fields
state.reload_model(app_label, self.model_name_lower)
}}}
I know 1.11 is a new version but I do not think it would crash the system
anyway - This
{{{
old_field = None
}}}
is causing the error. And as a good practice and good software engineering
if it is None why you did not even put there
{{{
try:
except
}}}
at least. Logan and I gave you a hint, and it has happened to 2 people
already within 3 months, so something must be going on in there.
--
Ticket URL: <https://code.djangoproject.com/ticket/28073#comment:11>
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/065.7663a1f205af4b9050cfe1036e14c581%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.