Djangorestframework-simplejwt: How do i add new fields to OutstandingToken Model, i just want to store the device id for push Notification

Created on 28 Apr 2021  路  4Comments  路  Source: jazzband/djangorestframework-simplejwt

question

All 4 comments

Sorry for lack of flexibility. Regardless, you'll first need to subclass the model. Before we come out with a patch, you'll need to patch the import:

# In settings.py, you'll still need to add the blacklist app
from django.db import models

from rest_framework_simplejwt.token_blacklist.models import BlacklistedToken as _BT, OutstandingToken as _OT

class OutstandingToken(_OT):
    device_id = models.CharField(max_length=100)

class BlacklistedToken(_BT):
    # FK needs to point to this new model
    token = models.OneToOneField(OutstandingToken, on_delete=models.CASCADE)

from rest_framework_simplejwt import token
# monkeypatch for less work all around. Just make sure you test this
# in your unit tests in case when you upgrade something breaks.
token.OutstandingToken = OutstandingToken
token.BlacklistedToken = BlacklistedToken

jenkins

After adding new fields and running migrations, results into two OutstandingToken Models is that i am going to manage it?

if yes, then how will i add new generated tokens into mu new OutstandingToken Model.

Closing. This seems to be resolved (at the least with the last comment)

Was this page helpful?
0 / 5 - 0 ratings