Questions tagged [modeladmin]

The modeladmin module allows you to add any model in your project to the Wagtail admin.

81 questions
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
55
votes
13 answers

Disable link to edit object in django's admin (display list only)?

In Django's admin, I want disable the links provided on the "select item to change" page so that users cannot go anywhere to edit the item. (I am going to limit what the users can do with this list to a set of drop down actions - no actual editing…
thornomad
  • 6,707
  • 10
  • 53
  • 78
47
votes
3 answers

Django: accessing the model instance from within ModelAdmin?

I've got a model for Orders in a webshop application, with an auto-incrementing primary key and a foreign key to itself, since orders can be split into multiple orders, but the relationship to the original order must be maintained. class…
JK Laiho
  • 3,538
  • 6
  • 35
  • 42
31
votes
7 answers

change list display link in django admin

I am trying to change the link for an object in the django admin list display. Here is what I have so far: class FooModelAdmin(admin.ModelAdmin): fields = ('foo','bar') list_display = ('foo_link','bar') def foo_link(self,obj): …
tomfmason
  • 1,039
  • 1
  • 11
  • 15
9
votes
1 answer

Wagtail ModelAdmin read only

Using Wagtails Modeladmin: Is there any way to disable edit & delete options leaving only the inspect view? A possible approach that I can think of, is extending the template, removing the edit & delete buttons and then somehow disable the edit and…
Cristián
  • 363
  • 3
  • 13
9
votes
2 answers

Wagtail ModelAdmin inline?

I am using wagtails' ModelAdmin module ( not the same as Django ModelAdmin) to add a custom Order model to the wagtail admin. This model has a foreign key to a custom Address model. I would like to display the Address model as an inline (like in…
jramm
  • 6,415
  • 4
  • 34
  • 73
7
votes
1 answer

ModelAdmin sorting?

With the Django Admin interface, how do you ensure that objects within HTML select multiple are sorted in some order (prefer alphabetical)? The issue is that I have 3 models - CD, Song, Singer. One the CD admin dashboard, Song is inline to CD and…
Chris Wherry
  • 328
  • 3
  • 6
4
votes
1 answer

Wagtail ModelAdmin cleaning and validating fields that depend on each other

In Django you can add a clean method to a form to validate fields that depend on each other: def clean_recipients(self): data = self.cleaned_data['recipients'] if "fred@example.com" not in data: raise ValidationError("You have…
allcaps
  • 10,945
  • 1
  • 33
  • 54
4
votes
3 answers

How to manipulate form fields in Django dynamically within ModelAdmin?

I have a field (slug) that is "required" in the model, but want to change the field in the ModelAdmin class to be optional. If the user doesn't fill it in, it is automatically filled in by another field (name). class SomeModel(model.Model): name =…
GoogleDroid
  • 41
  • 1
  • 2
4
votes
2 answers

Is there a way to add a custom "response" for boolean summary fields in Silverstripe model admin?

I want my booleans to give a more friendlier response then true/false. I have seen that I can do Boolan.Nice but that will give me yes/no. I have used: class AboutusGallery extends DataObject{ private static $db = [ 'Description' =>…
4
votes
1 answer

Show filter-form in Silverstripe's ModelAdmin by default

I added a ModelAdmin to my silverstripe site. This includes a filter form, which slides down when the user clicks the loupe icon in the frontend. How can I make the form visible by default (without user interaction)? Up to now I tried to call the…
hendra
  • 2,531
  • 5
  • 22
  • 34
4
votes
3 answers

How do you unregister a model in wagtail modeladmin?

I need to do the equivalent of... 'admin.site.unregister(Value)' but for a model registered with wagtailmodeladmin using 'modeladmin_register(Value)' in wagtail_hooks.py. How do you do that?
4
votes
1 answer

Scaffold ListBox multiple select in ModelAdmin Filter for DataObject with Enum

Currently the automatic scaffolding for search fields where there is an enum produces a drop down only allowing one selection to be made. I'm interested in using existing filters to change this to allow multiple selections. Given the following…
Barry
  • 3,303
  • 7
  • 23
  • 42
4
votes
1 answer

Django Many to Many and admin

I have a django ap which has a rather complicated model setup. I ended up using multi level composition to create a hierarchical model. All the relations are one to one, so I could have use inheritance but I chose not to so that i would benefit from…
Tim
  • 2,134
  • 3
  • 26
  • 40
4
votes
1 answer

SilverStripe 3: ModelAdmin with DataObject with $has_many to DataObject gives error

In SilverStripe 3 I have two related DataObjects, Order and OrderItem. Order has many OrderItems. OrderItem has one Order. I am managing Order with ModelAdmin. I can create a new OrderItem but when it tries to load I get the following…
1
2 3 4 5 6