In Django Admin how do I disable the Delete link

0 votes
I've managed to disable the "Delete selected" action. Easy.

But a user can still click on an item and then there's the red Delete link at the bottom.
Aug 13, 2020 in Python by kartik
• 37,520 points
2,293 views

1 answer to this question.

0 votes

Hello @kartik,

Simple you can use this code:

class DeleteNotAllowedModelAdmin(admin.ModelAdmin):
    # Other stuff here
    def has_delete_permission(self, request, obj=None):
        return False

Hope it helps!!
ThanK you!

answered Aug 13, 2020 by Niroj
• 82,840 points

Related Questions In Python

0 votes
0 answers

how do i install django in my system for the project?

can you tell me the procedure for ...READ MORE

May 3, 2019 in Python by Waseem
• 4,540 points
740 views
0 votes
1 answer

In NumPy how do I get the maximum of subsets? Python

You can use np.maximum.reduceat: >>> _, idx = np.unique(g, ...READ MORE

answered Nov 9, 2018 in Python by Nymeria
• 3,560 points
1,623 views
+1 vote
1 answer
0 votes
1 answer

How to temporarily disable a foreign key constraint in MySQL?

Hello @kartik, To turn off foreign key constraint ...READ MORE

answered Jun 23, 2020 in Python by Niroj
• 82,840 points
2,507 views
0 votes
1 answer

How do I use Django templates without the rest of Django?

Hello @kartik, Let's say you have this important ...READ MORE

answered Jun 23, 2020 in Python by Niroj
• 82,840 points
1,586 views
0 votes
1 answer

How do I add a link from the Django admin page of one object to the admin page of a related object?

Hello @kartik, Set show_change_link to True (False by default) in your inline ...READ MORE

answered Jun 12, 2020 in Python by Niroj
• 82,840 points
10,654 views
0 votes
1 answer

How can I disable the Django Celery admin modules?

Hello @kartik, To be more specific, in admin.py of any ...READ MORE

answered Jun 12, 2020 in Python by Niroj
• 82,840 points
1,576 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP