You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is generally a good idea to move logic out of serializers and into view classes. This makes the code more modular and easier to change. It also makes it easier to override serializers to change the structure of the API.
For example, if the logic for generating tokens was moved to the view class, then you could easily override the serializers to change the name of the "refresh" field to "refresh_token" in both requests body and responses. ( for example for being compatible with some other authentication systems ).
The text was updated successfully, but these errors were encountered:
@dpgraham4401 Hi, I tried this, but I encountered some limitations with the Django Rest Framework serializers regarding dynamic field names. I would be happy to see your solution.
It is generally a good idea to move logic out of serializers and into view classes. This makes the code more modular and easier to change. It also makes it easier to override serializers to change the structure of the API.
For example, if the logic for generating tokens was moved to the view class, then you could easily override the serializers to change the name of the "refresh" field to "refresh_token" in both requests body and responses. ( for example for being compatible with some other authentication systems ).
The text was updated successfully, but these errors were encountered: