Reputation: 69
My site has a django backend and it uses django-rest-auth package for authentication. I want to change this function inside rest-auth serializers:
path_to_my_virtenv/lib/python3.7/site-packages/rest_auth/registration/serializers.py
class RegisterSerializer(serializers.Serializer):
def get_cleaned_data(self):
return {
'username': self.validated_data.get('username', ''),
'password1': self.validated_data.get('password1', ''),
'email': self.validated_data.get('email', '')
}
I tried editing it directly and everything worked as I wanted, however I have a suspicion that it's not a good idea to edit files inside virtenv site-packages. Is there a way to override them from my django app? What is the best thing to do in my situation?
Upvotes: 2
Views: 190
Reputation: 953
You are right, editing this file is the worst option. You should never edit a third party applications code on your local machine (except you want to test some extreme case).
Django Rest Auth allows you to change Serializer class for all endpoints, you can find it on documentation.
Upvotes: 1