django-orchestra/orchestra/apps/accounts/serializers.py

18 lines
496 B
Python
Raw Normal View History

2014-05-08 16:59:35 +00:00
from rest_framework import serializers
from .models import Account
class AccountSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Account
fields = (
'url', 'username', 'type', 'language', 'register_date', 'is_active'
2014-05-08 16:59:35 +00:00
)
class AccountSerializerMixin(object):
def save_object(self, obj, **kwargs):
obj.account = self.context['request'].user.account
super(AccountSerializerMixin, self).save_object(obj, **kwargs)