Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

473
Vistas
/django.db.utils.IntegrityError: NOT NULL constraint failed/ after python manage.py migrate app zero

I had some mess with migrations in production and localy. Finally the situation was that in production there were only initial migration and localy there were 8 migrations or something. So I decided to use

python manage.py migrate app zero 

both in production and localy(django 1.8.7). In prodcution it worked but locally it raised error which didn't appear before after makemigrations or migrate command.

django.db.utils.IntegrityError: NOT NULL constraint failed: app_userprofile__new.phone_number

after few attempts to try different things, the error began to appear after migrate commands too.

The model itself :

class UserProfile(models.Model):
    user = models.OneToOneField(User)
    phone_number = models.IntegerField(null=True, blank=True, default=None)
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Check your local database.

This error usually happens when one or more records do not meet the NOT NULL requirement

    UserProfile.objects.filter(phone_number=None)

You can resolve this by filling the phone_number field of the objects found

Or deleting objects that do not have filled phone_number

UPDATE

Manage database changes with database migrations can prevent this type of situation

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda