Я пытаюсь построить игру в крестики-нолики.Моя страница администратора сайта Django выглядит пустой, и я не могу ее решить.
from django.db import models
from django.db.models import Q
from django.contrib.auth.models import User
GAME_STATUS_CHOICES ={
('F','First Player to move'),
('S', 'Second Player to move'),
('W', 'First Player Wins'),
('L', 'Second player Wins'),
('D', 'Draw')
}
class GameQuerySet(models.QuerySet):
def games_for_user(self, user):
return self.filter(
Q(first_player = user) | Q(second_player = user)
)
def active(self):
return self.filter(
Q(status='F') | Q(status='S')
)
class Game(models.Model):
first_player = models.ForeignKey(User, related_name =
"game_first_player", on_delete=models.CASCADE)
second_player = models.ForeignKey(User, related_name =
"game_second_player", on_delete=models.CASCADE)
start_time = models.DateTimeField(auto_now_add=True)
last_active = models.DateTimeField(auto_now=True)
status = models.CharField(max_length=1, default='F',
choices=GAME_STATUS_CHOICES)
objects = GameQuerySet.as_manager()
def __str__(self):
return "{0} vs {1}".format(
self.first_player, self.second_player)
class Move(models.Model):
x = models.IntegerField() # X and Y co-ordinates
y = models.IntegerField()
comment = models.CharField(max_length=300, blank= True)
by_first_player = models.BooleanField()
admin.py
from django.contrib import admin
from .models import Game, Move
admin.site.register(Move)
@admin.register(Game)
class GameAdmin(admin.ModelAdmin):
list_display = ('id','first_player','second_player','status')
list_editable = ('status',)
Я новичок в Джанго.Я застрял на этой проблеме некоторое время сейчас.Не удалось найти ответы.
Мой файл settings.py вроде бы в порядке,
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'gameplay',
'player',
]