Hello, I've encountered an issue with a Django project that I was running under CyberPanel 3.
Normally, under certain conditions, when new data is saved to the database, a new identifier is created for the field. While testing locally, it worked as expected, but in production, it failed to send.
After some research, I realized that signals must be loaded, either by adding them to the ready()
method in the apps.py
file, like this, and ensuring that the app is loaded into settings.py
, as in my case: 'users.apps.UsersConfig'
class UsersConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'users'
def ready(self):
import users.signals
Alternatively, you can add a line to the __init__.py
file as follows:
default_app_config = 'users.apps.UsersConfig'
If the issue persists after loading these, make sure that the receiver callback arguments contain the weak
attribute, which means the signals won't be garbage collected, like this:
@receiver(post_save, sender=Users, dispatch_uid="update_users", weak=False)
Also, ensure that the callback the receiver will use doesn't have the same name.
Enjoy!