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
1350
votes
28 answers

What is the difference between null=True and blank=True in Django?

When we add a model field in Django we generally write: models.CharField(max_length=100, null=True, blank=True) The same is done with ForeignKey, DecimalField etc. What is the basic difference between: null=True only blank=True only null=True and…
user993563
  • 18,601
  • 10
  • 42
  • 55
632
votes
24 answers

How to reset Django admin password?

I am using Django (version 1.3) and have forgotten both admin username and password. How to reset both? And is it possible to make a normal user into admin, and then remove admin status?
IamH1kc
  • 6,602
  • 4
  • 19
  • 17
412
votes
15 answers

Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields?

I have a Person model that has a foreign key relationship to Book, which has a number of fields, but I'm most concerned about author (a standard CharField). With that being said, in my PersonAdmin model, I'd like to display book.author using…
Huuuze
  • 15,528
  • 25
  • 72
  • 91
352
votes
12 answers

Django auto_now and auto_now_add

For Django 1.1. I have this in my models.py: class User(models.Model): created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) When updating a row I get: [Sun Nov 15 02:18:12 2009] [error]…
Paul Tarjan
  • 48,968
  • 59
  • 172
  • 213
306
votes
2 answers

How do I make many-to-many field optional in Django?

When you have a many-to-many relationship (related_name, not through) and you are trying to use the admin interface you are required to enter one of the relationships even though it does not have to exist for you to create the first entry. I'm…
DZ.
  • 3,181
  • 2
  • 15
  • 10
274
votes
24 answers

How to change site title, site header and index title in Django Admin?

How can I change the site title Django site admin, the site header Django administration and the index title Site administration in Django Admin?
samurailawngnome
  • 3,355
  • 3
  • 18
  • 17
227
votes
10 answers

Getting Django admin url for an object

Before Django 1.0 there was an easy way to get the admin url of an object, and I had written a small filter that I'd use like this: ... Basically I was using the url reverse function with the view name…
hasen
  • 161,647
  • 65
  • 194
  • 231
222
votes
2 answers

Django fix Admin plural

How do I change some models name from "Categorys" to "Categories" on admin site in the new dev django version? In the old version (whithout admin sites and admin models) you could just do…
Andriy Drozdyuk
  • 58,435
  • 50
  • 171
  • 272
196
votes
5 answers

Django Admin - Disable the 'Add' action for a specific model

I have a django site with lots of models and forms. I have many custom forms and formsets and inlineformsets and custom validation and custom querysets. Hence the add model action depends on forms that need other things, and the 'add model' in the…
Amandasaurus
  • 58,203
  • 71
  • 188
  • 248
190
votes
3 answers

Multiple ModelAdmins/views for same model in Django admin

How can I create more than one ModelAdmin for the same model, each customised differently and linked to different URLs? Let's say I have a Django model called Posts. By default, the admin view of this model will list all Post objects. I know I can…
Paul Stone
  • 6,056
  • 4
  • 21
  • 13
175
votes
11 answers

Troubleshooting "Related Field has invalid lookup: icontains"

I have the following models in models.py: class ListinoTraduttore(models.Model): traduttore = models.ForeignKey('Traduttore', related_name='Traduttore') linguaDa = models.ForeignKey(Lingua, related_name = "linguaDa") linguaA…
user1545895
  • 1,761
  • 2
  • 11
  • 5
168
votes
12 answers

How to override and extend basic Django admin templates?

How do I override an admin template (e.g. admin/index.html) while at the same time extending it (see https://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-vs-replacing-an-admin-template)? First - I know that this question has been…
Semmel
  • 2,526
  • 3
  • 21
  • 30
146
votes
8 answers

Add custom form fields that are not part of the model (Django)

I have a model registered on the admin site. One of its fields is a long string expression. I'd like to add custom form fields to the add/update pages of this model in the admin. Based on the values of these fields I will build the long string…
michalv82
  • 1,949
  • 4
  • 16
  • 17
142
votes
3 answers

list_display - boolean icons for methods

When defining the list_display array for a ModelAdmin class, if a BooleanField or NullBooleanField is given the UI will use nice looking icons instead of True/False text in the column. If a method that returns a boolean is given, however, it simply…
Jason McClellan
  • 2,931
  • 3
  • 23
  • 32
142
votes
3 answers

Django admin: how to sort by one of the custom list_display fields that has no database field

# admin.py class CustomerAdmin(admin.ModelAdmin): list_display = ('foo', 'number_of_orders') # models.py class Order(models.Model): bar = models.CharField[...] customer = models.ForeignKey(Customer) class Customer(models.Model): …
mike_k
  • 1,831
  • 2
  • 14
  • 12
1
2 3
99 100