﻿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
26413	Abstract model inheritance regression with string model references in 1.9	trkjgrdg	Simon Charette	"Django 1.9.4 on Python 3.4.0

Model definitions:

{{{
class A(models.Model):
	x = models.CharField(max_length=100)
class B(A):
	class Meta:
		abstract = True
	a = models.OneToOneField('A')
class C(B):
	pass
}}}

Run in shell:

{{{
C.objects.filter(x='')
}}}

Error:

{{{
Traceback (most recent call last):
  File ""<console>"", line 1, in <module>
  File ""/redacted/env/lib/python3.4/site-packages/django/db/models/manager.py"", line 122, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File ""/redacted/env/lib/python3.4/site-packages/django/db/models/query.py"", line 790, in filter
    return self._filter_or_exclude(False, *args, **kwargs)
  File ""/redacted/env/lib/python3.4/site-packages/django/db/models/query.py"", line 808, in _filter_or_exclude
    clone.query.add_q(Q(*args, **kwargs))
  File ""/redacted/env/lib/python3.4/site-packages/django/db/models/sql/query.py"", line 1243, in add_q
    clause, _ = self._add_q(q_object, self.used_aliases)
  File ""/redacted/env/lib/python3.4/site-packages/django/db/models/sql/query.py"", line 1269, in _add_q
    allow_joins=allow_joins, split_subq=split_subq,
  File ""/redacted/env/lib/python3.4/site-packages/django/db/models/sql/query.py"", line 1149, in build_filter
    lookups, parts, reffed_expression = self.solve_lookup_type(arg)
  File ""/redacted/env/lib/python3.4/site-packages/django/db/models/sql/query.py"", line 1035, in solve_lookup_type
    _, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta())
  File ""/redacted/env/lib/python3.4/site-packages/django/db/models/sql/query.py"", line 1345, in names_to_path
    targets = (final_field.remote_field.get_related_field(),)
  File ""/redacted/env/lib/python3.4/site-packages/django/db/models/fields/reverse_related.py"", line 241, in get_related_field
    field = self.model._meta.get_field(self.field_name)
AttributeError: 'str' object has no attribute '_meta'
}}}


The following model definitions work fine:

{{{
class A(models.Model):
	x = models.CharField(max_length=100)
class B(A):
	class Meta:
		abstract = True
	a = models.OneToOneField(A)
class C(B):
	pass
}}}
"	Bug	closed	Database layer (models, ORM)	1.9	Release blocker	fixed		Alex Hill Simon Charette	Ready for checkin	1	0	0	0	0	0
