0

I'm looking to make a django app that uses signals. (using django signals) There I would like to run some functions, and based on which output they give, send a message within the webpage. so for example, if the function fails i want to send a message saying it failed.

this is pretty much want i would want

in signals.py -----
def handle_event(request, *args, **kwargs):
    try: 
    --unimportant--
    except: 
       messages.error(request, 'error message') 
post_save.connect(handle_event, sender=Event)

how would i go about doing this?

gmv
  • 199
  • 1
  • 1
  • 11
  • What type of signals are you going to be handling, can you give an example? You may have to create some custom signals that receive the request – Iain Shelvington Mar 05 '22 at 19:05
  • im just trying to get edit and created signals. so when i create a new item(event in this case) i want the function to run, does that clarify? – gmv Mar 06 '22 at 16:08
  • Might be worth looking at this package https://github.com/benrobster/django-threadlocals. Several of those signals can be sent outside of a request/response context so you would have to handle that – Iain Shelvington Mar 11 '22 at 02:34

0 Answers0