Skip to content

Commit 0a78aa8

Browse files
DataGreedAsif Saif Uddin
authored and
Asif Saif Uddin
committed
registration_id no longer hard-coded in DeviceViewSetMixin
`lookup_field` was declared in `DeviceViewSetMixin` and never used. Instead the create method referred to string literal instead of this field. No the field is used. You can inherit from `DeviceViewSetMixin`, redefined the `lookup_field` and use if with your views instead of having to rewrite the `create` method yourself
1 parent eb83056 commit 0a78aa8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

push_notifications/api/rest_framework.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ class DeviceViewSetMixin(object):
138138
def create(self, request, *args, **kwargs):
139139
serializer = None
140140
is_update = False
141-
if SETTINGS.get("UPDATE_ON_DUPLICATE_REG_ID") and "registration_id" in request.data:
141+
if SETTINGS.get("UPDATE_ON_DUPLICATE_REG_ID") and self.lookup_field in request.data:
142142
instance = self.queryset.model.objects.filter(
143-
registration_id=request.data["registration_id"]
143+
registration_id=request.data[self.lookup_field]
144144
).first()
145145
if instance:
146146
serializer = self.get_serializer(instance, data=request.data)

0 commit comments

Comments
 (0)