I
I
Ilya Lopuga2019-08-04 09:29:58
Django
Ilya Lopuga, 2019-08-04 09:29:58

How to catch model change in cellery in Django?

stack:
Django
django-channels
celery
With channels, a small web socket server is implemented, in which, when connected, this is done:
post_save.connect(self.on_new_order, sender=Order)
Everything generally works well, if someone changes the model, then the event flies to the websocket and everyone is happy.
But, sometimes some abstract task in celery is launched, which receives the Order id and does some things with it. Naturally post_save does not work. What are the options?
First of all, he screwed everything up. in the second I read the doc about subscribing to the event about the finish of the task - it did not work at all.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alternativshik, 2019-08-04
@alternativshik

Naturally post_save does not work.
Unnatural if there is a save()

K
Karmaa, 2017-12-07
@AlexxFoexx

auth.php

<?php
  $password = '827ccb0eea8a706c4c34a16891f84e7b';  //пароль 12345
  header('Content-Type: text/html; charset=utf-8');

  if ( !empty( $_REQUEST['password'] ) and md5($_REQUEST['password']) == $password ) {
    session_start();

  
    $_SESSION['auth'] = true; 
  } else {
  
    if ( !empty($_REQUEST['password']) and md5($_REQUEST['password']) != $password ) {
      echo 'Неправильный пароль!<br>'; //выведем сообщение об ошибке
    }

  
?>
    <form action='auth.php' method='POST'> //ИЗМЕНЕНИЕ
      <input name='password' type='password'>
      <input type='submit' value='Отправить'>
    </form>
<?php
 	}
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question