MHeidarian
MHeidarian

Reputation: 43

Django admin model not update in admin

I use django admin to add data, i run makemigrations and migrate on my code but the Choice model won't update and i can't see the Choice model in admin.However the Question model is updated. Where is my mistake?

model.py:

class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)

def __str__(self):
    return self.choice_text

Upvotes: 2

Views: 2351

Answers (2)

Parsa Harooni
Parsa Harooni

Reputation: 70

Register it in admins.py file

admin.site.register(Choice)

Upvotes: 2

dfundako
dfundako

Reputation: 8324

You have to register it in admin.py

class ChoiceAdmin(admin.ModelAdmin):
    pass
admin.site.register(Choice, ChoiceAdmin)

Documentation for Django Admin https://docs.djangoproject.com/en/2.1/ref/contrib/admin/

Upvotes: 1

Related Questions