Questions tagged [django-admin]

Django's built-in, automatic admin interface (django.contrib.admin) which is part of the Django Web framework for the Python programming language.

One of the most powerful parts of Django is the automatic admin interface. It reads metadata from your models to provide a quick, model-centric interface where trusted users can manage content on your site. The admin’s recommended use is limited to an organization’s internal management tool. It’s not intended for building your entire front end around.

-- Django Admin Documentation

Resources:

10185 questions
104
votes
9 answers

Django admin, hide a model

At the root page of the admin site where registered models appear, I want to hide several models that are registered to the Django admin. If I directly unregister those, I am not able to add new records as the add new symbol "+" dissapears. How can…
Hellnar
  • 62,315
  • 79
  • 204
  • 279
101
votes
14 answers

Readonly models in Django admin interface?

How can I make a model completely read-only in the admin interface? It's for a kind of log table, where I'm using the admin features to search, sort, filter etc, but there is no need to modify the log. In case this looks like a duplicate, here's not…
Steve Bennett
  • 114,604
  • 39
  • 168
  • 219
99
votes
32 answers

model not showing up in django admin

I have ceated several django apps and stuffs for my own fun and so far everything has been working fine. Now I just created new project (django 1.2.1) and have run into trouble from 1st moments. I created new app - game and new model Game. I created…
Odif Yltsaeb
  • 5,575
  • 12
  • 49
  • 80
98
votes
7 answers

Override default queryset in Django admin

One of my models has a deleted flag, which is used to hide objects globally: class NondeletedManager(models.Manager): """Returns only objects which haven't been deleted""" def get_query_set(self): return super(NondeletedManager,…
Natan Yellin
  • 6,063
  • 5
  • 38
  • 57
94
votes
14 answers

Django Admin Show Image from Imagefield

While I can show an uploaded image in list_display is it possible to do this on the per model page (as in the page you get for changing a model)? A quick sample model would be: Class Model1(models.Model): image =…
Jeff_Hd
  • 2,174
  • 3
  • 19
  • 29
93
votes
6 answers

Using Django auth UserAdmin for a custom user model

From the Django.Contrib.Auth docs: Extending Django’s default User If you’re entirely happy with Django’s User model and you just want to add some additional profile information, you can simply subclass django.contrib.auth.models.AbstractUser and…
92
votes
3 answers

Form field description in django admin

How to add hint for the form field in django admin like in next example? (here: URL and Content descriptions are shown with gray color under field)
megido
  • 4,135
  • 6
  • 29
  • 33
92
votes
4 answers

How to add custom search box in Django-admin?

I know this is gonna be a very basic question. In Django, I have successfully created an admin panel. Now I want to add a custom search box in one of my field namely Photo field. But I don't know how to add custom search box in a django-admin panel.…
Md. Tanvir Raihan
  • 4,075
  • 9
  • 37
  • 70
90
votes
4 answers

Creating Custom Filters for list_filter in Django Admin

I would like to make custom filters for django admin instead of the normal 'is_staff' and 'is_superuser'. I have read this list_filter in Django docs. Custom Filters work in this way: from datetime import date from django.utils.translation import…
lakshmen
  • 28,346
  • 66
  • 178
  • 276
85
votes
7 answers

How to hide some fields in django-admin?

class Book(models.Model): title = models.CharField(..., null=True) type = models.CharField(...) author = models.CharField(...) I have a simple class in models.py. In admin I would like to hide title of the book (in book details form)…
pmoniq
  • 1,883
  • 2
  • 19
  • 22
83
votes
5 answers

How to add a calculated field to a Django model

I have a simple Employee model that includes firstname, lastname and middlename fields. On the admin side and likely elsewhere, I would like to display that as: lastname, firstname middlename To me the logical place to do this is in the model by…
cstrutton
  • 5,667
  • 3
  • 25
  • 32
80
votes
1 answer

How can I restrict Django's GenericForeignKey to a list of models?

Is there a way of telling django that a model having a contenttypes GenericForeignKey can only point to models from a predefined list? For example, I have 4 models: A, B, C, D and a model X that holds a GenericForeignKey. Can I tell X that only A &…
Geo
  • 93,257
  • 117
  • 344
  • 520
80
votes
5 answers

Django Admin: OneToOne Relation as an Inline?

I'm putting together the admin for a satchmo application. Satchmo uses OneToOne relations to extend the base Product model, and I'd like to edit it all on one page. Is it possible to have a OneToOne relation as an Inline? If not, what is the best…
Jiaaro
  • 74,485
  • 42
  • 169
  • 190
79
votes
7 answers

In Django Admin how do I disable the Delete link

I've managed to disable the "Delete selected" action. Easy. But a user can still click on an item and then there's the red Delete link at the bottom.
Peter Bengtsson
  • 7,235
  • 8
  • 44
  • 53
79
votes
3 answers

In the Django admin interface, is there a way to duplicate an item?

Just wondering if there is an easy way to add the functionality to duplicate an existing listing in the admin interface? In data entry we have run into a situation where a lot of items share generic data with another item, and to save time it would…
sesh
  • 1,460
  • 2
  • 11
  • 15