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

239
Vistas
Django 3.2 update AutoField to BigAutoField backward compatibility with foreign key relations

I'm running into a problem after updating my project from Django 2.2 to Django 3.2.

In Django 2.2 primary keys are created using AutoField meaning in MySql they are considered int(11) and all foreign keys from this table must also be int(11).

In Django 3.2 primary keys are now created with BigAutoField which in MySql creates type bigint(20). Therefore, I can't create any foreign key relations with old tables.

According to the documentation this can be changed in settings using:

DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

This works in creating primary keys as int(11) however, foreign key fields are still being created as bigint(20) meaning a relation can't be created because they must be of the same type.

Here says that you can change all your existing tables to BigAutoField but this also doesn't take care of foreign key relations.

Is there any way to change all primary keys and their relations to a different type easily? Am I missing something in the Django documentation where they also provide compatibility to related keys and well as primary keys?

I would obviously prefer to change all my existing data to work with BigAutoField if all future releases of Django will now use this as the default

over 4 years ago · Santiago Trujillo
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