Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

241
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda