﻿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
25503	Django 1.8 checks crash on ForeignKey to abstract model	Andriy Sokolovskiy	Mariusz Felisiak	"Consider some models:


{{{
from django.db import models


class ModelA(models.Model):
    test = models.CharField(blank=True, max_length=123)

    class Meta:
        abstract = True


class SomeOtherModel(models.Model):
    test_fk = models.ForeignKey(ModelA)

}}}


On django 1.8.5 it fails like:


{{{
Traceback (most recent call last):
  File ""manage.py"", line 10, in <module>
    execute_from_command_line(sys.argv)
  File ""/projpath/.env/lib/python2.7/site-packages/django/core/management/__init__.py"", line 351, in execute_from_command_line
    utility.execute()
  File ""/projpath/.env/lib/python2.7/site-packages/django/core/management/__init__.py"", line 343, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""/projpath/.env/lib/python2.7/site-packages/django/core/management/base.py"", line 394, in run_from_argv
    self.execute(*args, **cmd_options)
  File ""/projpath/.env/lib/python2.7/site-packages/django/core/management/base.py"", line 444, in execute
    self.check()
  File ""/projpath/.env/lib/python2.7/site-packages/django/core/management/base.py"", line 482, in check
    include_deployment_checks=include_deployment_checks,
  File ""/projpath/.env/lib/python2.7/site-packages/django/core/checks/registry.py"", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File ""/projpath/.env/lib/python2.7/site-packages/django/core/checks/model_checks.py"", line 28, in check_all_models
    errors.extend(model.check(**kwargs))
  File ""/projpath/.env/lib/python2.7/site-packages/django/db/models/base.py"", line 1205, in check
    errors.extend(cls._check_fields(**kwargs))
  File ""/projpath/.env/lib/python2.7/site-packages/django/db/models/base.py"", line 1282, in _check_fields
    errors.extend(field.check(**kwargs))
  File ""/projpath/.env/lib/python2.7/site-packages/django/db/models/fields/related.py"", line 1834, in check
    errors = super(ForeignKey, self).check(**kwargs)
  File ""/projpath/.env/lib/python2.7/site-packages/django/db/models/fields/related.py"", line 1507, in check
    errors.extend(self._check_unique_target())
  File ""/projpath/.env/lib/python2.7/site-packages/django/db/models/fields/related.py"", line 1527, in _check_unique_target
    for rel_field in self.foreign_related_fields)
  File ""/projpath/.env/lib/python2.7/site-packages/django/db/models/fields/related.py"", line 1527, in <genexpr>
    for rel_field in self.foreign_related_fields)
AttributeError: 'NoneType' object has no attribute 'unique'
}}}

On django 1.7 it throws error:

{{{
CommandError: System check identified some issues:

ERRORS:
blankapp.SomeOtherModel.test_fk: (fields.E300) Field defines a relation with model 'ModelA', which is either not installed, or is abstract.
}}}
"	Bug	closed	Database layer (models, ORM)	1.8	Release blocker	fixed		me@… felisiak.mariusz@…	Accepted	1	0	0	0	0	0
