Created
June 4, 2018 10:54
-
-
Save TarCV/03f35115e827c89cd19ab4df3cb8068d 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
from django.db import models | |
class Match(models.Model): | |
roundlimit = models.IntegerField() | |
scorelimit = models.IntegerField() | |
class Score(models.Model): | |
match = models.ForeignKey(Match, on_delete=models.PROTECT) | |
name = models.CharField(max_length=30) | |
score = models.IntegerField() |
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 tastypie import fields | |
from tastypie.resources import ModelResource | |
from tastypie.authorization import Authorization | |
from results.models import Match, Score | |
class MatchResource(ModelResource): | |
scores = fields.ToManyField('results.api.resources.ScoreResource', 'score_set', full=True) | |
class Meta: | |
queryset = Match.objects.all() | |
allowed_methods = ['get', 'post'] | |
authorization = Authorization() | |
class ScoreResource(ModelResource): | |
class Meta: | |
queryset = Score.objects.all() | |
allowed_methods = ['get'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment