It is impossible to add a non-nullable field 'id' to video without specifying a default

This is my models.py

from ast import Delete
from email.policy import default
from django.db import models
from django.contrib.auth.models import User

class Video(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    title=models.CharField(max_length=100, null=False)
    description=models.TextField(max_length=1000,null=True)
    video=models.FileField(upload_to="video/%y",null=False)

    def __str__(self):
        return self.title

class Euser(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    phone = models.CharField(max_length=10,null=True)
    birthdate = models.DateField(null=True,)
    profile_pic = models.ImageField(null=True, )
    cover_pic = models.ImageField( null=True, upload_to="images/%y")

    def __str__(self):
        return self.phone

when i try to makemigrations

It is impossible to add a non-nullable field 'id' to video without specifying a default. This is because the database needs something to populate existing rows. Please select a fix:

  1. Provide a one-off default now (will be set on all existing rows with a null value for this column)
  2. Quit and manually define a default value in models.py.

This error occurs... Please suggest me what should i do

and also suggest me about any changes in model

For a particular model, in the database, if records already exist add new fields to the model then it shows such an error. To overcome this problem, you have to set the new field as blank=True and null=True or you can set some default value to the new field using default='some_value'.

Back to Top