我的Django项目中有一个相对简单的模型(我应该注意到这个措辞很奇怪,因为应用程序本身被称为游戏'并且其中的模型是游戏,但是我会这样做稍后更改):
from django.db import models
class Game(models.Model):
player_turn = models.IntegerField(),
game_state = models.BooleanField(),
rolled = models.BooleanField(),
rolled_double = models.BooleanField(),
last_roll = models.IntegerField(),
test_text = models.CharField(max_length = 200),
在项目的主文件夹中显示
的settings.py文件INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'games.apps.GamesConfig',
]
和games / admin.py看起来像这样 来自django.contrib import admin
from .models import Game
admin.site.register(Game)
当我尝试运行' python3 manage.py makemigrations'它表明没有检测到任何变化(即使我随意更改游戏模型以测试效果),当我进入管理网站添加新游戏时,没有可用于编辑的字段,就像用户和组模型一样。模型本身显示在管理站点中,但没有任何字段。现在我跟随MDN Django教程(https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Models),似乎我已经完成了所有必要的步骤,所以有人能让我知道我可能会忘记做什么吗? / p>
我很乐意发布任何其他可能有用的代码。网站管理员的图片如下。提前谢谢。
答案 0 :(得分:3)
删除模型中每个字段后的所有逗号(',')并尝试makemigrations并迁移,然后检查管理面板
class Game(models.Model):
player_turn = models.IntegerField()
game_state = models.BooleanField()
rolled = models.BooleanField()
rolled_double = models.BooleanField()
last_roll = models.IntegerField()
test_text = models.CharField(max_length = 200)