Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 15491

Django models field not getting generated in database

$
0
0

I am creating a basic Django project. I am using the default db sqlite3. I have created an app product inside my main folder. So, my folder structure is like this:

-project  -djangoproject  -products    -models.py-manage.py

I am adding my new product model in models.py but when I am running python3 manage.py makemigrations I am checking my migration file. The model is getting created and there is an id field also in it but no other field of my product is coming in my migrations file. I also ran the command python3 manage.py migrations and checked my database. Only id field is present in the product table. I am not able to understand the cause of this problem.

Here is the look at my migration file and models.py file:

from django.db import modelsclass Product(models.Model):    name: models.CharField(max_length=200)    price: models.FloatField()    stock: models.IntegerField()    image_url: models.CharField(max_length=2083)
# Generated by Django 5.0.3 on 2024-03-21 04:46from django.db import migrations, modelsclass Migration(migrations.Migration):    initial = True    dependencies = [        ('products', '0004_delete_offer_delete_product'),    ]    operations = [        migrations.CreateModel(            name='Product',            fields=[                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),            ],        ),    ]

Django version: 5

If anyone knows the reason then please comment or post your answer. It will be really helpful for me.

Thanks in advance.


Viewing all articles
Browse latest Browse all 15491

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>