5

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.

Main Site Admin Game Info Add Game

2 Answers 2

13

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)
2
  • 3
    haha chill bro, we all learn from our mistakes only, when you come from a different programming language to python, we make this kind of mistakes, anyways glad to help you :)
    – Exprator
    Commented Jan 12, 2018 at 4:50
  • Thanks so much! makemigrations kept deleting my fields and they weren't showing up in the admin view, and this was the issue! Do you know why this happens? Commented Sep 20, 2021 at 5:38
-1

If you have (, comma) after every field entry just remove it...i spend some time to find it ...

1
  • 1
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Apr 21, 2022 at 11:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.