FAQ: The admin ============== 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. --------------------------------------------------------------------------------------------------------------------------- The login cookie isn't being set correctly, because the domain of the cookie sent out by Django doesn't match the domain in your browser. Try these two things: * Set the :setting:`SESSION_COOKIE_DOMAIN` setting in your admin config file to match your domain. For example, if you're going to "http://www.example.com/admin/" in your browser, in "myproject.settings" you should set :setting:`SESSION_COOKIE_DOMAIN` = 'www.example.com'. * Some browsers (Firefox?) don't like to accept cookies from domains that don't have dots in them. If you're running the admin site on "localhost" or another domain that doesn't have a dot in it, try going to "localhost.localdomain" or "127.0.0.1". And set :setting:`SESSION_COOKIE_DOMAIN` accordingly. 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. ----------------------------------------------------------------------------------------------------------------------------------------------------------- If you're sure your username and password are correct, make sure your user account has :attr:`~django.contrib.auth.models.User.is_active` and :attr:`~django.contrib.auth.models.User.is_staff` set to True. The admin site only allows access to users with those two fields both set to True. How do I automatically set a field's value to the user who last edited the object in the admin? ----------------------------------------------------------------------------------------------- The :class:`~django.contrib.admin.ModelAdmin` class provides customization hooks that allow you to transform an object as it saved, using details from the request. By extracting the current user from the request, and customizing the :meth:`~django.contrib.admin.ModelAdmin.save_model` hook, you can update an object to reflect the user that edited it. See :ref:`the documentation on ModelAdmin methods ` for an example. How do I limit admin access so that objects can only be edited by the users who created them? --------------------------------------------------------------------------------------------- The :class:`~django.contrib.admin.ModelAdmin` class also provides customization hooks that allow you to control the visibility and editability of objects in the admin. Using the same trick of extracting the user from the request, the :meth:`~django.contrib.admin.ModelAdmin.get_queryset` and :meth:`~django.contrib.admin.ModelAdmin.has_change_permission` can be used to control the visibility and editability of objects in the admin. My admin-site CSS and images showed up fine using the development server, but they're not displaying when using mod_wsgi. --------------------------------------------------------------------------------------------------------------------------- See :ref:`serving the admin files ` in the "How to use Django with mod_wsgi" documentation. My "list_filter" contains a ManyToManyField, but the filter doesn't display. ---------------------------------------------------------------------------- Django won't bother displaying the filter for a ``ManyToManyField`` if there are fewer than two related objects. For example, if your :attr:`~django.contrib.admin.ModelAdmin.list_filter` includes :doc:`sites `, and there's only one site in your database, it won't display a "Site" filter. In that case, filtering by site would be meaningless. Some objects aren't appearing in the admin. ------------------------------------------- Inconsistent row counts may be caused by missing foreign key values or a foreign key field incorrectly set to :attr:`null=False `. If you have a record with a :class:`~django.db.models.ForeignKey` pointing to a non-existent object and that foreign key is included is :attr:`~django.contrib.admin.ModelAdmin.list_display`, the record will not be shown in the admin changelist because the Django model is declaring an integrity constraint that is not implemented at the database level. How can I customize the functionality of the admin interface? ------------------------------------------------------------- You've got several options. If you want to piggyback on top of an add/change form that Django automatically generates, you can attach arbitrary JavaScript modules to the page via the model's class Admin :ref:`js parameter `. That parameter is a list of URLs, as strings, pointing to JavaScript modules that will be included within the admin form via a ``