Debian Codegraph @

docs/faq/admin.txt

raw
1 ==============
2 FAQ: The admin
3 ==============
4
5 I can't log in. When I enter a valid username and password, it just brings up the login page again, with no error messages.
6 ===========================================================================================================================
7
8 The login cookie isn't being set correctly, because the domain of the cookie
9 sent out by Django doesn't match the domain in your browser. Try setting the
10 :setting:`SESSION_COOKIE_DOMAIN` setting to match your domain. For example, if
11 you're going to "https://www.example.com/admin/" in your browser, set
12 ``SESSION_COOKIE_DOMAIN = 'www.example.com'``.
13
14 I can't log in. When I enter a valid username and password, it brings up the login page again, with a "Please enter a correct username and password" error.
15 ===========================================================================================================================================================
16
17 If you're sure your username and password are correct, make sure your user
18 account has :attr:`~django.contrib.auth.models.User.is_active` and
19 :attr:`~django.contrib.auth.models.User.is_staff` set to True. The admin site
20 only allows access to users with those two fields both set to True.
21
22 How do I automatically set a field's value to the user who last edited the object in the admin?
23 ===============================================================================================
24
25 The :class:`~django.contrib.admin.ModelAdmin` class provides customization hooks
26 that allow you to transform an object as it saved, using details from the
27 request. By extracting the current user from the request, and customizing the
28 :meth:`~django.contrib.admin.ModelAdmin.save_model` hook, you can update an
29 object to reflect the user that edited it. See :ref:`the documentation on
30 ModelAdmin methods <model-admin-methods>` for an example.
31
32 How do I limit admin access so that objects can only be edited by the users who created them?
33 =============================================================================================
34
35 The :class:`~django.contrib.admin.ModelAdmin` class also provides customization
36 hooks that allow you to control the visibility and editability of objects in the
37 admin. Using the same trick of extracting the user from the request, the
38 :meth:`~django.contrib.admin.ModelAdmin.get_queryset` and
39 :meth:`~django.contrib.admin.ModelAdmin.has_change_permission` can be used to
40 control the visibility and editability of objects in the admin.
41
42 My admin-site CSS and images showed up fine using the development server, but they're not displaying when using mod_wsgi.
43 =========================================================================================================================
44
45 See :ref:`serving the admin files <serving-the-admin-files>`
46 in the "How to use Django with mod_wsgi" documentation.
47
48 My "list_filter" contains a ManyToManyField, but the filter doesn't display.
49 ============================================================================
50
51 Django won't bother displaying the filter for a ``ManyToManyField`` if there
52 are no related objects.
53
54 For example, if your :attr:`~django.contrib.admin.ModelAdmin.list_filter`
55 includes :doc:`sites </ref/contrib/sites>`, and there are no sites in your
56 database, it won't display a "Site" filter. In that case, filtering by site
57 would be meaningless.
58
59 Some objects aren't appearing in the admin.
60 ===========================================
61
62 Inconsistent row counts may be caused by missing foreign key values or a
63 foreign key field incorrectly set to :attr:`null=False
64 <django.db.models.Field.null>`. If you have a record with a
65 :class:`~django.db.models.ForeignKey` pointing to a nonexistent object and
66 that foreign key is included is
67 :attr:`~django.contrib.admin.ModelAdmin.list_display`, the record will not be
68 shown in the admin changelist because the Django model is declaring an
69 integrity constraint that is not implemented at the database level.
70
71 How can I customize the functionality of the admin interface?
72 =============================================================
73
74 You've got several options. If you want to piggyback on top of an add/change
75 form that Django automatically generates, you can attach arbitrary JavaScript
76 modules to the page via the model's class Admin :ref:`js parameter
77 <modeladmin-asset-definitions>`. That parameter is a list of URLs, as strings,
78 pointing to JavaScript modules that will be included within the admin form via
79 a ``<script>`` tag.
80
81 If you want more flexibility than is feasible by tweaking the auto-generated
82 forms, feel free to write custom views for the admin. The admin is powered by
83 Django itself, and you can write custom views that hook into the authentication
84 system, check permissions and do whatever else they need to do.
85
86 If you want to customize the look-and-feel of the admin interface, read the
87 next question.
88
89 The dynamically-generated admin site is ugly! How can I change it?
90 ==================================================================
91
92 We like it, but if you don't agree, you can modify the admin site's
93 presentation by editing the CSS stylesheet and/or associated image files. The
94 site is built using semantic HTML and plenty of CSS hooks, so any changes you'd
95 like to make should be possible by editing the stylesheet.
96
97 .. _admin-browser-support:
98
99 What browsers are supported for using the admin?
100 ================================================
101
102 The admin provides a fully-functional experience to the recent versions of
103 modern, web standards compliant browsers. On desktop this means Chrome, Edge,
104 Firefox, Opera, Safari, and others.
105
106 On mobile and tablet devices, the admin provides a responsive experience for
107 web standards compliant browsers. This includes the major browsers on both
108 Android and iOS.
109
110 Depending on feature support, there *may* be minor stylistic differences
111 between browsers. These are considered acceptable variations in rendering.
112
113 What assistive technologies are supported for using the admin?
114 ==============================================================
115
116 The admin is intended to be compatible with a wide range of assistive
117 technologies, but there are currently many blockers. The support target is all
118 latest versions of major assistive technologies, including Dragon, JAWS, NVDA,
119 Orca, TalkBack, Voice Control, VoiceOver iOS, VoiceOver macOS, Windows Contrast
120 Themes, ZoomText, and screen magnifiers.