diff options
| author | Luke Plant <L.Plant.98@cantab.net> | 2011-01-28 14:08:25 +0000 |
|---|---|---|
| committer | Luke Plant <L.Plant.98@cantab.net> | 2011-01-28 14:08:25 +0000 |
| commit | c24bdf044ba23f2aa09ea4637a368ea86fd1c128 (patch) | |
| tree | 9e9afcb8dc6803205570e5e047539537528b9ea8 /django/db/models | |
| parent | 22eaf77f9d3541e007d3e1b6292710bb6a016dff (diff) | |
Fixed #15103 - SuspiciousOperation with limit_choices_to and raw_id_fields
Thanks to natrius for the report.
This patch also fixes some unicode bugs in affected code.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15347 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models')
| -rw-r--r-- | django/db/models/fields/related.py | 2 | ||||
| -rw-r--r-- | django/db/models/options.py | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index 6e18f6d470..1318706040 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -901,6 +901,8 @@ class ForeignKey(RelatedField, Field): # don't get a related descriptor. if not self.rel.is_hidden(): setattr(cls, related.get_accessor_name(), ForeignRelatedObjectsDescriptor(related)) + if self.rel.limit_choices_to: + cls._meta.related_fkey_lookups.append(self.rel.limit_choices_to) if self.rel.field_name is None: self.rel.field_name = cls._meta.pk.name diff --git a/django/db/models/options.py b/django/db/models/options.py index 882d2f5709..2f64c56b00 100644 --- a/django/db/models/options.py +++ b/django/db/models/options.py @@ -55,6 +55,10 @@ class Options(object): self.abstract_managers = [] self.concrete_managers = [] + # List of all lookups defined in ForeignKey 'limit_choices_to' options + # from *other* models. Needed for some admin checks. Internal use only. + self.related_fkey_lookups = [] + def contribute_to_class(self, cls, name): from django.db import connection from django.db.backends.util import truncate_name |
