Commits

Anonymous committed 4f21757

The autocomplete_view now takes into account limit_choices_to.

Comments (0)

Files changed (1)

django/contrib/admin/options.py

         if field not in self.autocomplete_fields or query is None:
             raise Http404
         
-        rel_model = getattr(self.model, field).field.rel.to
-        # XXX are we considering limit_choices_to ?
-        queryset = rel_model._default_manager.all()
+        relation = getattr(self.model, field).field.rel
+        queryset = relation.to._default_manager.complex_filter(relation.limit_choices_to)
         settings = self.autocomplete_fields[field]
-        
+
         def construct_search(field_name):
             # use different lookup methods depending on the notation
             if field_name.startswith('^'):