not null constraint failed django

You must create a migration, where you will specify default value for a new field, since you don't want it to be null. If null is not required, simply add null=True and create and run migration.

Here is what the above code is Doing:
1. We import the models module from the django.db package.
2. We import the datetime module from the datetime package.
3. We import the User model from the django.contrib.auth.models module.
4. We create a new class called Post, which subclasses django.db.models.Model.
5. We define a text field, which is limited to 140 characters.
6. We define a date-time field, which auto_now_add=True tells Django to set the field to now when the object is first created.
7. We define a foreign key, which tells Django each Post is written by a single User.
8. We define a string representation of the model. This is what you’ll see in the Django admin site and is used in the shell.