'Django model fields not appearing in admin
I have a relatively simple model in my Django project (I should note that the wording is weird in that the app itself is called 'games' and within it the model is Game but I'll change this later):
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),
with a settings.py file in the main folder of the project showing
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'games.apps.GamesConfig',
]
and games/admin.py looks like this from django.contrib import admin
from .models import Game
admin.site.register(Game)
When I try to run 'python3 manage.py makemigrations' it shows that no changes are detected (even if I arbitrarily change the Game model to test the effect) and when I go into the admin site to add a new game there are no fields available to edit like there are for the User and Group models. The model itself shows up in the admin site but without any fields. Right now I'm following along the MDN Django tutorial (https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Models) and it seems like I'm following all of the necessary steps so can someone let me know what I might be forgetting to do?
I'd be happy to post any other code that might be helpful if needed. Images of site admin are below. Thanks in advance.
Solution 1:[1]
remove all the commas (',') after each field in the model and try to makemigrations and migrate and then check the admin panel
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)
Solution 2:[2]
If you have (, comma) after every field entry just remove it...i spend some time to find it ...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Exprator |
Solution 2 |