Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Admin page shows only one model field of many

models.py

from django.db import models

class items(models.Model):
    price = models.IntegerField(),
    name = models.TextField(max_length=100),
    category = models.CharField(max_length=100)

When i try to insert a data on admin page it is showing only category field and I’m can fill only this one field.

Also it is showing an extra s in table names for no reason.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I am expecting that there should be 3 columns to fill data: name, price and category but getting only one of them.

https://i.stack.imgur.com/hk2Fx.png

>Solution :

No comma needed, try this:

from django.db import models

# Create your models here.
class items(models.Model):
    price = models.IntegerField()
    name = models.TextField(max_length=100)
    category = models.CharField(max_length=100)

And do not foget to make migrations:

python3 manage.py makemigrations
python3 manage.py migrate
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading