-1

My Django App was working fine until I added this 'author' field to my Model:

from django.db import models
from django.contrib.auth.models import User

class Post(models.Model):

author = models.ForeignKey(User, on_delete=models.CASCADE)
content = models.TextField(blank=True, null=True, max_length=280)

I'm literally copying it from a article I found (from 2022), so I don't get what's wrong. This is the error the console is showing:

enter image description here

Here's the repository -> https://github.com/mateomaza/SocialMediaProject

Mateo
  • 9
  • 1
  • It seems some problem with your migration files itself, it maybe possible that you made migrations so many times while creating model relationships. – Sunderam Dubey Oct 10 '22 at 18:59
  • Does this answer your question? ['NOT NULL constraint failed' after adding to models.py](https://stackoverflow.com/questions/25964312/not-null-constraint-failed-after-adding-to-models-py) – Sunderam Dubey Oct 10 '22 at 19:01

1 Answers1

-2

Just looking at the stack trace the author_id field is probably null somewhere.

error django.db.utils.IntegrityError: NOT NULL constraint failed https://www.codingforentrepreneurs.com/comments/13752/