django-push-notifications icon indicating copy to clipboard operation
django-push-notifications copied to clipboard

[Issue] Module saves id of user instead of username

Open uber1geek opened this issue 7 years ago • 4 comments

I have a custom user model, however, when i register a device, the fcm-django model registers the id column of the related username or (partner_id in my case) to the user_id column.

I want the user_id column to have username from the users table and not the id of the particular username row

I have attached screenshots of the tables, how can i fix this? I need to send push notifications to a particular username(partner_id) which is my unique identifier for data across other tables.

PS: partner_id == username.

My users table: screen shot 2017-11-28 at 4 12 27 pm

django push notifications table: screen shot 2017-11-28 at 4 57 50 pm

uber1geek avatar Nov 28 '17 11:11 uber1geek

@uber1geek The user column is a foreign key, the value stored is the id reference to your user table. To get the devices using the partner_id from your user table try:

devices = GCMDevice.objects.filter(user__partner_id='X1234')

jamaalscarlett avatar Nov 28 '17 16:11 jamaalscarlett

@jamaalscarlett Thanks, I didn't think of that before. I was doing client = User.objects.get(partner_id=self.request.user.username) and devices = GCMDevice.objects.filter(user_id=client.id) which worked but the way you suggested looks better.

Thanks :)

uber1geek avatar Nov 29 '17 07:11 uber1geek

@jamaalscarlett How do we decide when the device is inactive? Does it depend on FCM_ERROR_TIMEOUT? What would be an ideal error timeout in your opinion?

uber1geek avatar Nov 29 '17 09:11 uber1geek

@uber1geek There is an active flag on the device model.

jamaalscarlett avatar Dec 01 '17 16:12 jamaalscarlett