Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit signal on active change #23

Open
BojanKogoj opened this issue May 31, 2017 · 2 comments
Open

Emit signal on active change #23

BojanKogoj opened this issue May 31, 2017 · 2 comments

Comments

@BojanKogoj
Copy link

active is being changed through update(), which does not emit a signal that I need. Would it make sense to add signal to update?

Something similar to the following in https://github.com/xtrinch/fcm-django/blob/master/fcm_django/models.py#L38

class FCMDeviceQuerySet(models.query.QuerySet):

    def update(self, **kwargs):
        post_save.send(self.__class__, **kwargs)  # some signal
        return super(FCMDeviceQuerySet, self).update(**kwargs)
@xtrinch
Copy link
Owner

xtrinch commented May 31, 2017

Well the question at hand is how much worse will the performance be, if you call save on individual models so that the post_save handler would be triggered.

What is the use case of using post_save? Is it anything that could be handled differently?

@Andrew-Chen-Wang
Copy link
Contributor

I think adding a signal for something scalable like notifications would be potentially harmful. Over at djangorestframework-simplejwt, I considered the same problem and came to the conclusion that we could add a setting saying whether we wanted to emit a signal. I don't think a signal will be necessary though. On the one hand, if a device is being deactivated, you can receive the ids from the QuerySet API response (from #160). From DRF, override some views. And from admins, override the ModelAdmin class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants