diff --git a/AUTHORS b/AUTHORS
index df5bbb82ab..a46cf625cb 100644
a
|
b
|
answer newbie questions, and generally made Django that much better:
|
689 | 689 | Robert Wittams |
690 | 690 | Rob Hudson <http://rob.cogit8.org/> |
691 | 691 | Robin Munn <http://www.geekforgod.com/> |
| 692 | Rodrigo Pinheiro Marques de Araújo <fenrrir@gmail.com> |
692 | 693 | Romain Garrigues <romain.garrigues.cs@gmail.com> |
693 | 694 | Ronny Haryanto <http://ronny.haryan.to/> |
694 | 695 | Ross Poulton <ross@rossp.org> |
diff --git a/django/contrib/admin/checks.py b/django/contrib/admin/checks.py
index c8e05bde7c..96194f7c74 100644
a
|
b
|
class BaseModelAdminChecks:
|
104 | 104 | except FieldDoesNotExist: |
105 | 105 | return refer_to_missing_field(field=field_name, option=label, model=model, obj=obj, id='admin.E037') |
106 | 106 | else: |
107 | | if not (field.many_to_many or field.many_to_one): |
| 107 | if not (field.many_to_many or field.many_to_one or field.one_to_one): |
108 | 108 | return must_be( |
109 | | 'a foreign key or a many-to-many field', |
| 109 | 'a foreign key, a one-to-one field or a many-to-many field', |
110 | 110 | option=label, obj=obj, id='admin.E038' |
111 | 111 | ) |
112 | 112 | related_admin = obj.admin_site._registry.get(field.remote_field.model) |
diff --git a/tests/admin_checks/models.py b/tests/admin_checks/models.py
index 3336ce878e..e41def39e1 100644
a
|
b
|
class Influence(models.Model):
|
64 | 64 | content_type = models.ForeignKey(ContentType, models.CASCADE) |
65 | 65 | object_id = models.PositiveIntegerField() |
66 | 66 | content_object = GenericForeignKey('content_type', 'object_id') |
| 67 | |
| 68 | |
| 69 | class User(models.Model): |
| 70 | name = models.CharField(max_length=1024) |
| 71 | |
| 72 | |
| 73 | class ProfileUser(models.Model): |
| 74 | user = models.OneToOneField(User, models.CASCADE) |
| 75 | birthdate = models.DateField() |
diff --git a/tests/admin_checks/tests.py b/tests/admin_checks/tests.py
index f4fabef301..454e36baf7 100644
a
|
b
|
from django.core import checks
|
6 | 6 | from django.test import SimpleTestCase, override_settings |
7 | 7 | |
8 | 8 | from .models import ( |
9 | | Album, Author, Book, City, Influence, Song, State, TwoAlbumFKAndAnE, |
| 9 | Album, Author, Book, City, Influence, ProfileUser, Song, State, |
| 10 | TwoAlbumFKAndAnE, User, |
10 | 11 | ) |
11 | 12 | |
12 | 13 | |
… |
… |
class SystemChecksTestCase(SimpleTestCase):
|
127 | 128 | admin.site.unregister(Book) |
128 | 129 | admin.site.unregister(Author) |
129 | 130 | |
| 131 | def test_autocomplete_onetoone_field(self): |
| 132 | |
| 133 | class UserAdmin(admin.ModelAdmin): |
| 134 | search_fields = ('name', ) |
| 135 | |
| 136 | class ProfileUserAdmin(admin.ModelAdmin): |
| 137 | autocomplete_fields = ('user', ) |
| 138 | |
| 139 | admin.site.register(User, UserAdmin) |
| 140 | admin.site.register(ProfileUser, ProfileUserAdmin) |
| 141 | try: |
| 142 | self.assertEqual(admin.site.check(None), []) |
| 143 | finally: |
| 144 | admin.site.unregister(User) |
| 145 | admin.site.unregister(ProfileUser) |
| 146 | |
130 | 147 | def test_field_name_not_in_list_display(self): |
131 | 148 | class SongAdmin(admin.ModelAdmin): |
132 | 149 | list_editable = ["original_release"] |