Questions tagged [django-modeladmin]
132 questions
49
votes
21 answers
Ordering admin.ModelAdmin objects in Django Admin
Let's say I have my pizza application with Topping and Pizza classes and they show in Django Admin like this:
PizzaApp
-
Toppings >>>>>>>>>> Add / Change
Pizzas >>>>>>>>>> Add / Change
But I want them like…

Rui Ferreira
- 623
- 1
- 5
- 8
25
votes
4 answers
Override save on Django InlineModelAdmin
That question might look similar to this one, but it's not...
I have a model structure like :
class Customer(models.Model):
....
class CustomerCompany(models.Model):
customer = models.ForeignKey(Customer)
type =…

Mp0int
- 18,172
- 15
- 83
- 114
13
votes
1 answer
Exact field search in the Django admin
I'm trying to configure the Django admin bindings for a specific model so that I can quickly filter by the exact value of a specific field. I know I can manually tamper with the GET parameters to do this:
?fieldname__exact=foobar
What I can't seem…

Pieter
- 893
- 1
- 8
- 20
10
votes
1 answer
add help text to a read only field in django admin view
Below is my admin view:
@admin.register(AuditStashAwsMasterPolicies)
class AuditPoliciesAdmin(reversion.VersionAdmin):
exclude = ['source_policy_path', 'source_state', 'target_state']
readonly_fields = ['comparison_date', 'source',…

Justin S
- 1,409
- 4
- 22
- 38
8
votes
1 answer
Properly using Foreign Key references in search_fields, Django admin
I've got a weird conundrum that I need some help with in Django 1.8.4 using python 3.4 in a virtual-env.
I've got 2 models in 2 different apps... as follows with multiple Foreign Key references.
Inventory App
class InventoryItem(models.Model):
…

Dan2theR
- 159
- 2
- 11
8
votes
2 answers
How can I override the "media" property of Django's ModelAdmin and make it dynamic?
Ultimately, I'd like to include/exclude certain javascript file(s) based on... whatever. Simply defining the Media class, by itself, won't work since that is only evaluated once.
I know I can do this by making a custom admin template, but I'm…

Troy
- 21,172
- 20
- 74
- 103
7
votes
1 answer
django admin save_model not saving model changes
This is my admin.py:
class TransactionInfoAdmin(admin.ModelAdmin):
search_fields=['transactionId','subscriptionInfo__customerNumber']
save_on_top = False
def has_add_permission(self,request):
return False
def…

Maverick
- 2,738
- 24
- 91
- 157
6
votes
1 answer
Django - Get object id in render_change_form (ModelAdmin)
I have these two models and modeladmin. When adding a new host in the list of available hostuser only appear hostusers that are not assigned to another host.
The issue is if I edit an already created host its actual hostuser id is also filtered so I…

José Antonio Yáñez Jiménez
- 93
- 1
- 8
5
votes
2 answers
How To Edit ManyToManyField In Django Admin list Display Page?
I want to add Many2Many fields editable in Django admin list_display page.
The model structure as below,
class Genre(models.Model):
name = models.CharField(max_length=250, unique=True)
class Movie(models.Model):
name =…

Amal chempazhanthy
- 53
- 1
- 3
5
votes
2 answers
Django admin interface to display aggregates
I want to use django admin interface to display aggregates of data in a model. Ex: Model has following fields [employee name, salary, month] I want aggregate table with fields [month, total_salary_paid, cumulative_of_month_salaries_paid]. how do I…

Rahul Attuluri
- 175
- 2
- 7
5
votes
1 answer
Django admin: use one-to-one relationship in search_fields
I am trying to to add a search to my model admin list page using the following Model and ModelAdmin classes:
models.py
from django.contrib.auth.models import User
class UserProfile(models.Model):
user = models.OneToOneField(User)
…

Ryu_hayabusa
- 3,666
- 2
- 29
- 32
4
votes
2 answers
How to display a value where there is none in Django admin?
Is there a Djangotastic way to display a default value for a field in the admin when there isn't a value? Like 'n/a', but not to save that to the database?
When I set all the fields in the model below to readonly in the admin, the front-end display…

jackiekazil
- 5,696
- 4
- 21
- 20
4
votes
2 answers
Django Admin exclude model from index and app page
I want to hide some models from admin index page and app page. For example, these that I have visible in inlines as related objects.
One more point, I want to keep the ability to work with change_view and add_view, but not list_view of that…

wowkin2
- 5,895
- 5
- 23
- 66
4
votes
2 answers
Django admin site change_list view customization
I have a ModelAdmin subclass for my gradeScalesSettings model:
@admin.register(gradeScalesSetting)
class gradeScalesSettingAdmin(admin.ModelAdmin):
list_display = ('configuration_select', 'NumberOfGrades', 'Rounding','Precision', 'Status',)
…
user12295267
4
votes
2 answers
How to display list_filter with count of related objects in django admin?
How can I display the count of related objects after each filter in list_filter in django admin?
class Application(TimeStampModel):
name = models.CharField(verbose_name='CI Name', max_length=100, unique=True)
description =…

Stryker
- 5,732
- 1
- 57
- 70