Created
September 18, 2014 10:51
-
-
Save aitzol/1ca7d2fe8f3f15d345eb to your computer and use it in GitHub Desktop.
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
models.py | |
class TribualUserInTribe(models.Model): | |
user = models.ForeignKey(TribualUser) | |
tribe = models.ForeignKey(Tribe) | |
#Unique together | |
played = models.IntegerField(default=0) | |
elo = models.IntegerField(default=2000,db_index=True) | |
k = models.IntegerField(default=40) | |
win = models.IntegerField(default=0) | |
loose = models.IntegerField(default=0) | |
draw = models.IntegerField(default=0) | |
def get_tribe_id(self): | |
return self.tribe.id | |
def get_tribe_title(self): | |
return self.tribe.title | |
serializer.py | |
class TribualUserInTribeSerializer(serializers.ModelSerializer): | |
id = serializers.Field(source='get_tribe_id') | |
title = serializers.Field(source='get_tribe_title') | |
class Meta: | |
model = TribualUserInTribe | |
fields = ('id','title','elo') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment