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

177
Visualizações
How to reload modules in Django Shell?

I'm working with Django and I use the Django shell all the time. The annoying part is that while the Django server reloads with code changes, the shell doesn't, so every time I make a change to a method I'm testing, I need to exit the shell and restart it, re-import all the modules I need, reset all the variables I need, etc. While iPython history saves a lot of typing on this, this is still a pain. Is there a way to make the Django shell reload automatically, the same way the Django development server does?

I know about reload(), but I import a lot of models and generally use from app.models import * syntax, so reload() isn't much help.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I'd suggest using the IPython autoreload extension.

 ./manage.py shell In [1]: %load_ext autoreload In [2]: %autoreload 2

And from now on, all imported modules will be updated before evaluating.

 In [3]: from x import print_something In [4]: print_something() Out[4]: 'Something' # Do changes in print_something method in x.py file. In [5]: print_something() Out[5]: 'Something else'

It also works if something was imported before the %load_ext autoreload command.

 ./manage.py shell In [1]: from x import print_something In [2]: print_something() Out[2]: 'Something' # Do changes in print_something method in x.py file. In [3]: %load_ext autoreload In [4]: %autoreload 2 In [5]: print_something() Out[5]: 'Something else'
over 4 years ago · Santiago Trujillo Relatório
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