Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6195129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:24:55+00:00 2026-05-24T03:24:55+00:00

I want admins to be notified when certain objects are deleted but I also

  • 0

I want admins to be notified when certain objects are deleted but I also want to determine which user is performing the delete.

Is it possible?

This is the code:

# models.py
# signal to notify admins when nodes are deleted
from django.db.models.signals import post_delete
from settings import DEBUG

def notify_on_delete(sender, instance, using, **kwargs):
    ''' Notify admins when nodes are deleted. Only for production use '''
    if DEBUG:
        #return False
        pass
    # prepare context
    context = {
        'node': instance,
        'site': SITE
    }
    # notify admins that want to receive notifications
    notify_admins(instance, 'email_notifications/node-deleted-admin_subject.txt', 'email_notifications/node-deleted-admin_body.txt', context, skip=False)

post_delete.connect(notify_on_delete, sender=Node)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:24:56+00:00Added an answer on May 24, 2026 at 3:24 am

    I doubt it’s possible using the built-in signals (there is no User implicitly tied to a delete operation, and because of Django’s loose coupling the database layer doesn’t deal with HttpRequest objects). I would create my own signal which provides a user argument and send it in whatever view the delete operation takes place, something like:

    # myapp/signals.py
    from django.dispatch import Signal
    my_post_delete = Signal(providing_args=['instance', 'user'])
    
    # myapp/models.py
    from myapp.signals import my_post_delete
    ...
    my_post_delete.connect(notify_on_delete, sender=Node)
    
    # myapp/views.py
    from myapp.signals import my_post_delete
    ...
    @login_required
    def my_delete_view(request, ...)
        ...
        instance = Node.objects.get(...)
        instance.delete()
        my_post_delete.send(sender=Node, instance=instance, user=request.user)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

...I want to Show the 'delete' button when user is an admin, and show
My RealEstate PHP Application have following user groups, Admins, Moderators Agents i want to
I want to have a web based admin to upload, delete files and folders
I want to assign the decimal variable "trans" to the double variable "this.Opacity". decimal
I've an Admin area and I want only Admins to enter the area. I
Scenario. 3rd party admins want to administer systems with PS remoting/direct login of clients
I have a database in Access 2003 that I only want certain people to
The scenario is this: I have some users on my site. A user has
I want to promote users to moderators, admins, etc. What about scoring and game
I have a control panel that allows admins to enter in certain search criteria

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.