MCPcopy
hub / github.com/django/django / changelist_view

Method changelist_view

django/contrib/admin/options.py:2298–2470  ·  view source on GitHub ↗

The 'change list' admin view for this model.

(self, request, extra_context=None)

Source from the content-addressed store, hash-verified

2296
2297 @csrf_protect_m
2298 def changelist_view(self, request, extra_context=None):
2299 """
2300 The 'change list' admin view for this model.
2301 """
2302 from django.contrib.admin.views.main import ERROR_FLAG
2303
2304 app_label = self.opts.app_label
2305 if not self.has_view_or_change_permission(request):
2306 raise PermissionDenied
2307
2308 try:
2309 cl = self.get_changelist_instance(request)
2310 except IncorrectLookupParameters:
2311 # Wacky lookup parameters were given, so redirect to the main
2312 # changelist page, without parameters, and pass an 'invalid=1'
2313 # parameter via the query string. If wacky parameters were given
2314 # and the 'invalid=1' parameter was already in the query string,
2315 # something is screwed up with the database, so display an error
2316 # page.
2317 if ERROR_FLAG in request.GET:
2318 return SimpleTemplateResponse(
2319 "admin/invalid_setup.html",
2320 {
2321 "title": _("Database error"),
2322 },
2323 )
2324 return HttpResponseRedirect(request.path + "?" + ERROR_FLAG + "=1")
2325
2326 # If the request was POSTed, this might be a bulk action or a bulk
2327 # edit. Try to look up an action or confirmation first, but if this
2328 # isn't an action the POST will fall through to the bulk edit check,
2329 # below.
2330 action_failed = False
2331 selected = request.POST.getlist(helpers.ACTION_CHECKBOX_NAME)
2332
2333 # RemovedInDjango70Warning: When the deprecation ends, replace with:
2334 # actions = self.get_actions(
2335 # request, action_location=ActionLocation.CHANGE_LIST
2336 # )
2337 actions = self._get_actions_with_action_location(
2338 request, action_location=ActionLocation.CHANGE_LIST
2339 )
2340 # Actions with no confirmation
2341 if (
2342 actions
2343 and request.method == "POST"
2344 and "index" in request.POST
2345 and "_save" not in request.POST
2346 ):
2347 if selected:
2348 response = self.response_action(
2349 request,
2350 queryset=cl.get_queryset(request),
2351 action_location=ActionLocation.CHANGE_LIST,
2352 )
2353 if response:
2354 return response
2355 else:

Callers

nothing calls this directly

Tested by

no test coverage detected