Created
March 18, 2017 15:46
-
-
Save greut/62e7bfb951778316ae303c4b77ba3d8a to your computer and use it in GitHub Desktop.
One view, multiple lists.
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.views.generic import ListView | |
from django.contrib.auth.mixins import LoginRequiredMixin | |
from .models import Game | |
class GameListView(LoginRequiredMixin, ListView): | |
template_name = "games.html" | |
model = Game | |
ordering = '-id' | |
def open_games(self): | |
qs = self.get_queryset() | |
return qs.filter(type=Game.GameType.Open) | |
def running_games(self): | |
return self.get_queryset().filter(type=Game.GameType.Running) | |
def done_games(self): | |
return self.get_queryset().filter(type=Game.GameType.Done) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment