NOT NULL constraint failed: new__store_product.category_id

after i add category field to my model i am facing this error. where is the problem?

from django.db import models

class Category(models.Model):
    name = models.CharField(max_length=50)

    def __str__(self):

class Product(models.Model):
    name = models.CharField(max_length=50)
    price = models.IntegerField()
    des = models.TextField()
    category = models.ForeignKey(Category, on_delete=models.CASCADE,default=1)
    image = models.ImageField(upload_to='products/pics')

    def __str__(self):
        return`enter code here`

We’ll need a tad more info. Is this error occurring during migrations? Form submissions?

error occurs: python migrate

sir, can you tell me what to do now( my topic: not null constraint)

Are these the only models in your application? That reference above to the error message doesn’t seem to apply to these models shown here.

Are these the complete models, or are there fields you’re not showing?

Also, it might be helpful if you posted the full error message you’re receiving from the migrate command.

sir, after deleting some migrations file it works fine. Thank you sir, for your time.

I’m glad to see you have it working, but I want strongly caution you about deleting migration files - especially migrations that may have been previously applied. You can effectively break migrations by deleting files you shouldn’t

I understand that there are times when it’s the fastest and easiest way to resolve some set of problems. Just be aware that there are significant risks associated with doing that if you’re not full aware of what you’re doing.

Sir, now i understand. I have spent some time reading & now i know what that error was indicating.
Thank you sir.