modeladmin

Wagtail ModelAdmin read only

陌路散爱 提交于 2019-12-06 01:44:45
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 delete view. Is there any cleaner approach? EDIT: Thanks to Loic answer I could figure out. The PermissionHelper source code was also very helpful to figure out the correct method to override. Complete answer for only showing inspect view class ValidationPermissionHelper(PermissionHelper): def user_can_list(self, user): return True def user_can

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

耗尽温柔 提交于 2019-11-29 20:17:07
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 of fields). I see that Django has the ability to choose which fields display the link , however, I can't see how I can have none of them. class HitAdmin(admin.ModelAdmin): list_display = ('user','ip','user_agent','hitcount') search_fields = ('ip','user_agent') date_hierarchy = 'created' list_display_links = [] # doesn't work, goes to default Any

Django: accessing the model instance from within ModelAdmin?

半腔热情 提交于 2019-11-27 17:41:56
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 Order(models.Model): ordernumber = models.AutoField(primary_key=True) parent_order = models.ForeignKey('self', null=True, blank=True, related_name='child_orders') # .. other fields not relevant here I've registered an OrderAdmin class for the admin site. For the detail view, I've included parent_order in the fieldsets attribute. Of course, by default this

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

北慕城南 提交于 2019-11-26 02:35:14
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 list_display : class PersonAdmin(admin.ModelAdmin): list_display = ['book.author',] I've tried all of the obvious methods for doing so, but nothing seems to work. Any suggestions? imjoevasquez As another option, you can do look ups like: class UserAdmin(admin.ModelAdmin): list_display = (..., 'get_author') def get_author(self, obj): return obj.book.author

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

别等时光非礼了梦想. 提交于 2019-11-26 01:50:49
问题 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 list_display : class PersonAdmin(admin.ModelAdmin): list_display = [\'book.author\',] I\'ve tried all of the obvious methods for doing so, but nothing seems to work. Any suggestions? 回答1: As another option, you can do look ups like: class UserAdmin