Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I disable the "Recent Actions" widget from Django Admin interface?

I dont want to show the recent action widget in django admin site.I don't know how to get this done.

like image 511
Anshul Avatar asked Jul 13 '11 04:07

Anshul


People also ask

How do I hide recent actions in Django Admin?

html template to disable the display. There's a sidebar block you might want to change/remove. Conditionally enabling or disabling actions ModelAdmin. get_actions(request) Finally, you can conditionally enable or disable actions on a per-request (and hence per-user basis) by overriding ModelAdmin.

How do I restrict access to admin pages in Django?

Django admin allows access to users marked as is_staff=True . To disable a user from being able to access the admin, you should set is_staff=False . This holds true even if the user is a superuser. is_superuser=True .

How can I remove extra's from Django admin panel?

Answer 1: You can add another class called Meta in your model to specify plural display name. For example, if the model's name is Category , the admin displays Categorys , but by adding the Meta class, we can change it to Categories .


1 Answers

you can override the admin/index.html template to disable the display. There's a sidebar block you might want to change/remove.

Conditionally enabling or disabling actions ModelAdmin.get_actions(request) Finally, you can conditionally enable or disable actions on a per-request (and hence per-user basis) by overriding ModelAdmin.get_actions().

This returns a dictionary of actions allowed. The keys are action names, and the values are (function, name, short_description) tuples.

Most of the time you'll use this method to conditionally remove actions from the list gathered by the superclass. For example, if I only wanted users whose names begin with 'J' to be able to delete objects in bulk, I could do the following:

class MyModelAdmin(admin.ModelAdmin):
    ...

    def get_actions(self, request):
        actions = super(MyModelAdmin, self).get_actions(request)
        if request.user.username[0].upper() != 'J':
            del actions['delete_selected']
        return actions

i edited the answer you may find more like this at https://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/

like image 107
Devjosh Avatar answered Nov 15 '22 09:11

Devjosh