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
137
votes
7 answers

Django admin: How to display the field marked as "editable=False" in the model?

Even though a field is marked as 'editable=False' in the model, I would like the admin page to display it. Currently, it hides the field altogether.. How can this be achieved?
GabiMe
  • 18,105
  • 28
  • 76
  • 113
136
votes
4 answers

How to show a many-to-many field with "list_display" in Django Admin?

class Product(models.Model): products = models.CharField(max_length=256) def __unicode__(self): return self.products class PurchaseOrder(models.Model): product = models.ManyToManyField('Product') vendor =…
Mdjon26
  • 2,145
  • 4
  • 19
  • 29
130
votes
15 answers

Resize fields in Django Admin

Django tends to fill up horizontal space when adding or editing entries on the admin, but, in some cases, is a real waste of space, when, i.e., editing a date field, 8 characters wide, or a CharField, also 6 or 8 chars wide, and then the edit box…
Andor
  • 1,998
  • 3
  • 16
  • 24
128
votes
9 answers

Django "xxxxxx Object" display customization in admin action sidebar

I would like to change the default behavior of how the admin recent changes sidebar displays the name of "objects" added. Refer to the picture below: I would like to change how these are named in the Admin. Ideally, I would like to be able to…
patrickn
  • 2,501
  • 4
  • 22
  • 21
125
votes
3 answers

How can I set a default value for a field in a Django model?

Suppose I have a model: class SomeModel(models.Model): id = models.AutoField(primary_key=True) a = models.CharField(max_length=10) b = models.CharField(max_length=7) Currently I am using the default Django admin to create/edit objects…
Yuval Adam
  • 161,610
  • 92
  • 305
  • 395
121
votes
8 answers

django admin make a field read-only when modifying obj but required when adding new obj

In admin I would like to disable a field when modifying object, but make it required when adding new object. Whats the django way to go about this one?
frnhr
  • 12,354
  • 9
  • 63
  • 90
119
votes
3 answers

Can I make an admin field not required in Django without creating a form?

Every time I enter in a new player in the Admin portion of Django I get an error message that says "This field is required.". Is there a way to make a field not required without having to create a custom form? Can I do this within models.py or…
bigmike7801
  • 3,908
  • 9
  • 49
  • 77
117
votes
10 answers

DateTimeField doesn't show in admin system

How come my "date" field doesn't come up in the admin system? In my admin.py file i have from django.contrib import admin from glasses.players.models import * admin.site.register(Rating) and the Rating model has a field called "date" which looks…
dotty
  • 40,405
  • 66
  • 150
  • 195
114
votes
6 answers

Tying in to Django Admin's Model History

The Setup: I'm working on a Django application which allows users to create an object in the database and then go back and edit it as much as they desire. Django's admin site keeps a history of the changes made to objects through the admin…
akdom
  • 32,264
  • 27
  • 73
  • 79
114
votes
18 answers

Default filter in Django admin

How can I change the default filter choice from 'ALL'? I have a field named as status which has three values: activate, pending and rejected. When I use list_filter in Django admin, the filter is by default set to 'All' but I want to set it to…
ha22109
  • 8,036
  • 13
  • 44
  • 48
113
votes
9 answers

How to override css in Django Admin?

I want to change certain css in admin django like base.css. Is it better to change directly in the django library? How can I override it in the best way?
rajan sthapit
  • 4,194
  • 10
  • 42
  • 66
113
votes
5 answers

A Better Django Admin ManyToMany Field Widget

I find the the Django Admin's default models.ManyToManyField widget to be cumbersome to use. It's the HTML select element and if you have a lot of Objects of the "other" model then it's quite impractical to actually find the "other" Objects you want…
Chris W.
  • 37,583
  • 36
  • 99
  • 136
111
votes
20 answers

How to drop all tables from the database with manage.py CLI in Django?

How can I drop all tables from a database using manage.py and command line? Is there any way to do that executing manage.py with appropriate parameters so I can execute it from a .NET application?
kmalmur
  • 2,809
  • 3
  • 29
  • 37
106
votes
9 answers

Django-Admin: CharField as TextArea

I have class Cab(models.Model): name = models.CharField( max_length=20 ) descr = models.CharField( max_length=2000 ) class Cab_Admin(admin.ModelAdmin): ordering = ('name',) list_display = ('name','descr', ) # what to write…
maxp
  • 5,454
  • 7
  • 28
  • 30
106
votes
14 answers

Unique BooleanField value in Django?

Suppose my models.py is like so: class Character(models.Model): name = models.CharField(max_length=255) is_the_chosen_one = models.BooleanField() I want only one of my Character instances to have is_the_chosen_one == True and all others to…
user82216