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

178
Vistas
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 Respuestas
Responde la pregunta

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 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