python – How to solve NOT NULL constraint with django ForeignKey?


As I am new to django I am getting this NOT NULL constraint with django’s model ForeignKey. I am trying to add the User as a foreign key to the table Offer

my models.py

from django.conf import settings

class Offer(models.Model):
    item = models.CharField(max_length=100)
    stock = models.IntegerField()
    discount = models.FloatField()
    user = models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE,)

this is how I save it in views.py

    offer = Offer(item=item,stock=stock,discount=discount)
    offer.save()

How do I solve this