I'm trying to create a profile model for the general user that Django has by default, but it seems that when creating a user from
manage.py I get the error that the title has along with this one:
django.db.utils.IntegrityError: NOT NULL constraint failed: userprofiles_profile.birth_date
This is the
models.py of the Profile application
from django.contrib.auth.models import User from django.db import models from django.db.models.signals import post_save from django.dispatch import receiver # Create your models here. class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) bio = models.TextField(blank=True) website = models.URLField(blank=True) birth_date = models.DateField(blank=True, default=None) def __str__(self): return self.user.username @receiver(post_save, sender=User) def create_user_profile(sender, instance, created, **kwargs): if created: Profile.objects.create(user=instance) @receiver(post_save, sender=User) def save_user_profile(sender, instance, **kwargs): instance.profile.save()
I do not know if the signals have anything to do with the inconvenience I'm presenting and I do not know if they need any other part of the code to help me solve this problem.
Thanks in advance to who can help me.