Skip to content

Commit

Permalink
Fixed #1113, thanks to Jacob for spotting the deeper bug
Browse files Browse the repository at this point in the history
git-svn-id: http://code.djangoproject.com/svn/django/branches/0.91-bugfixes@3935 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
ubernostrum committed Oct 25, 2006
1 parent e35be34 commit b457108
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions django/contrib/admin/views/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,16 @@ def get_modules_and_options(self, app_label, module_name, request):
self.mod, self.opts = _get_mod_opts(app_label, module_name)
if not request.user.has_perm(app_label + '.' + self.opts.get_change_permission()):
raise PermissionDenied

self.lookup_mod, self.lookup_opts = self.mod, self.opts

lookup_mod, lookup_opts = self.mod, self.opts
if self.opts.one_to_one_field:
lookup_mod = self.opts.one_to_one_field.rel.to.get_model_module()
lookup_opts = lookup_mod.Klass._meta
# If lookup_opts doesn't have admin set, give it the default meta.Admin().
if not lookup_opts.admin:
lookup_opts.admin = meta.Admin()

self.lookup_mod, self.lookup_opts = lookup_mod, lookup_opts

def get_search_parameters(self, request):
# Get search parameters from the query string.
Expand Down Expand Up @@ -226,6 +234,8 @@ def get_lookup_params(self):
or_queries.append(meta.Q(**{'%s__icontains' % field_name: bit}))
complex_queries.append(reduce(operator.or_, or_queries))
lookup_params['complex'] = reduce(operator.and_, complex_queries)
if opts.one_to_one_field:
lookup_params.update(opts.one_to_one_field.rel.limit_choices_to)
self.lookup_params = lookup_params

def change_list(request, app_label, module_name):
Expand Down

0 comments on commit b457108

Please sign in to comment.