Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

newforms-admin: Backwards-incompatible change: Removed undocumented A…

…dmin.manager option in favor of Admin.change_list_queryset() method

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 08328ea commit 4fc14c6f7a04bb3f5b147fff6f840efb1b2f04e8 @adrianholovaty adrianholovaty committed
5 django/contrib/admin/
@@ -95,6 +95,9 @@ def has_delete_permission(self, request, object_id):
opts = self.opts
return request.user.has_perm(opts.app_label + '.' + opts.get_delete_permission())
+ def change_list_queryset(self, request):
+ return self.model._default_manager.get_query_set()
def add_view(self, request, show_delete=False, form_url='', post_url=None, post_url_continue='../%s/', object_id_override=None):
"The 'add' admin view for this model."
from django.contrib.admin.views.main import render_change_form
@@ -280,7 +283,7 @@ def change_list_view(self, request):
raise PermissionDenied
cl = ChangeList(request, self.model, self.list_display, self.list_display_links, self.list_filter,
- self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page)
+ self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self)
except IncorrectLookupParameters:
# Wacky lookup parameters were given, so redirect to the main
# changelist page, without parameters, and pass an 'invalid=1'
8 django/contrib/admin/views/
@@ -293,11 +293,11 @@ def _get_deleted_objects(deleted_objects, perms_needed, user, obj, opts, current
class ChangeList(object):
- def __init__(self, request, model, list_display, list_display_links, list_filter, date_hierarchy, search_fields, list_select_related, list_per_page):
+ def __init__(self, request, model, list_display, list_display_links, list_filter, date_hierarchy, search_fields, list_select_related, list_per_page, model_admin):
self.model = model
self.opts = model._meta
self.lookup_opts = self.opts
- self.manager = self.opts.admin.manager
+ self.root_query_set = model_admin.change_list_queryset(request)
self.list_display = list_display
self.list_display_links = list_display_links
self.list_filter = list_filter
@@ -372,7 +372,7 @@ def get_results(self, request):
if isinstance(self.query_set._filters, models.Q) and not self.query_set._filters.kwargs:
full_result_count = result_count
- full_result_count = self.manager.count()
+ full_result_count = self.root_query_set.count()
can_show_all = result_count <= MAX_SHOW_ALL_ALLOWED
multi_page = result_count > self.list_per_page
@@ -424,7 +424,7 @@ def get_ordering(self):
return order_field, order_type
def get_query_set(self):
- qs = self.manager.get_query_set()
+ qs = self.root_query_set
lookup_params = self.params.copy() # a dictionary of the query string
if lookup_params.has_key(i):
2  django/db/models/
@@ -137,7 +137,7 @@ def add_to_class(cls, name, value):
# of ModelAdmin.
cls._meta.ModelAdmin = type('ModelAdmin', (value, ModelAdmin), {})
# This AdminOptions stuff is legacy and will eventually be removed.
- value = AdminOptions(**dict([(k, v) for k, v in value.__dict__.items() if not k.startswith('_') and k not in ('list_display', 'list_display_links', 'list_filter', 'date_hierarchy', 'save_as', 'search_fields', 'list_select_related', 'list_per_page', 'ordering', 'save_on_top', 'js')]))
+ value = AdminOptions(**dict([(k, v) for k, v in value.__dict__.items() if not k.startswith('_') and k not in ('list_display', 'list_display_links', 'list_filter', 'date_hierarchy', 'save_as', 'search_fields', 'list_select_related', 'list_per_page', 'ordering', 'save_on_top', 'js', 'manager')]))
value.contribute_to_class(cls, name)
elif hasattr(value, 'contribute_to_class'):
value.contribute_to_class(cls, name)
6 django/db/models/
@@ -4,7 +4,6 @@
from django.db.models.fields import AutoField, FieldDoesNotExist
from django.db.models.loading import get_models
from django.db.models.query import orderlist2sql
-from django.db.models import Manager
from bisect import bisect
import re
@@ -199,9 +198,8 @@ def has_field_type(self, field_type, follow=None):
return self._field_types[field_type]
class AdminOptions(object):
- def __init__(self, fields=None, manager=None):
+ def __init__(self, fields=None):
self.fields = fields
- self.manager = manager or Manager()
def get_field_sets(self, opts):
"Returns a list of AdminFieldSet objects for this AdminOptions object."
@@ -220,8 +218,6 @@ def get_field_sets(self, opts):
def contribute_to_class(self, cls, name):
cls._meta.admin = self
- # Make sure the admin manager has access to the model
- self.manager.model = cls
class AdminFieldSet(object):
def __init__(self, name, classes, field_locator_func, line_specs, description):

0 comments on commit 4fc14c6

Please sign in to comment.
Something went wrong with that request. Please try again.