Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!