Created
September 26, 2017 12:09
-
-
Save elcolie/7f097642c4a752e76044c6938c49e097 to your computer and use it in GitHub Desktop.
serializers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from soken_web.apps.uploaded_files.models import CustomerFromExcel | |
from rest_framework import serializers | |
class ModelControllerSerializer(serializers.ModelSerializer): | |
class Meta: | |
abstract = True | |
def create(self, validated_data): | |
user = self.context['request'].user | |
validated_data['created_user'] = user | |
validated_data['updated_user'] = user | |
return super().create(validated_data) | |
def update(self, instance, validated_data): | |
user = self.context['request'].user | |
validated_data['updated_user'] = user | |
return super().update(instance, validated_data) | |
class CustomerFromExcelSerializer(ModelControllerSerializer): | |
class Meta: | |
model = CustomerFromExcel | |
fields = [ | |
'id', | |
'file', | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment