diff --git a/django/db/models/query.py b/django/db/models/query.py
index 7492039..6f66c3e 100644
a
|
b
|
class RawQuerySet(object):
|
1402 | 1402 | # Construct model instance and apply annotations |
1403 | 1403 | skip = set() |
1404 | 1404 | for field in self.model._meta.fields: |
1405 | | if field.name not in model_init_kwargs.keys(): |
| 1405 | if field.attname not in model_init_kwargs.keys(): |
1406 | 1406 | skip.add(field.attname) |
1407 | 1407 | |
1408 | 1408 | if skip: |
diff --git a/tests/modeltests/raw_query/models.py b/tests/modeltests/raw_query/models.py
index fb5503d..6188d58 100644
a
|
b
|
class Coffee(models.Model):
|
22 | 22 | brand = models.CharField(max_length=255, db_column="name") |
23 | 23 | |
24 | 24 | class Reviewer(models.Model): |
25 | | reviewed = models.ManyToManyField(Book) |
26 | | No newline at end of file |
| 25 | reviewed = models.ManyToManyField(Book) |
| 26 | |
| 27 | class FriendlyAuthor(Author): |
| 28 | pass |
diff --git a/tests/modeltests/raw_query/tests.py b/tests/modeltests/raw_query/tests.py
index ceed674..38b784d 100644
a
|
b
|
|
1 | | from django.test import TestCase |
2 | | from datetime import datetime |
3 | | from models import Author, Book, Coffee, Reviewer |
| 1 | from datetime import date |
| 2 | |
4 | 3 | from django.db.models.sql.query import InvalidQuery |
| 4 | from django.test import TestCase |
| 5 | |
| 6 | from models import Author, Book, Coffee, Reviewer, FriendlyAuthor |
| 7 | |
5 | 8 | |
6 | 9 | class RawQueryTests(TestCase): |
7 | 10 | |
… |
… |
class RawQueryTests(TestCase):
|
197 | 200 | self.assertEquals(len(first_two), 2) |
198 | 201 | |
199 | 202 | self.assertRaises(TypeError, lambda: Author.objects.raw(query)['test']) |
| 203 | |
| 204 | def test_inheritance(self): |
| 205 | # date is the end of the Cuban Missile Crisis, I have no idea when |
| 206 | # Wesley was bron |
| 207 | f = FriendlyAuthor.objects.create(first_name="Wesley", last_name="Chun", |
| 208 | dob=date(1962, 10, 28)) |
| 209 | query = "SELECT * FROM raw_query_friendlyauthor" |
| 210 | self.assertEqual( |
| 211 | [o.pk for o in FriendlyAuthor.objects.raw(query)], [f.pk] |
| 212 | ) |