duck-booking-tool/api/views.py

15 lines
417 B
Python
Raw Normal View History

2014-12-23 08:56:04 +00:00
from django.shortcuts import render, get_object_or_404
2015-01-05 15:13:08 +00:00
from django.views import generic
2014-12-23 08:56:04 +00:00
from booking.models import Duck
2015-01-05 15:13:08 +00:00
class DuckCompListView(generic.ListView):
template_name = 'api/duck_comp_list.json'
context_object_name = 'comp_list'
2014-12-23 08:56:04 +00:00
2015-01-05 15:13:08 +00:00
def get_queryset(self):
duck_id = self.kwargs['duck_id']
duck = get_object_or_404(Duck, pk = duck_id)
2014-12-23 08:56:04 +00:00
2015-01-05 15:13:08 +00:00
return duck.duckcompetence_set.all()