1

I'm using Django 3.2, Python 3.9 and bpython==0.21 for a more useable shell. However, I notice when I start using my shell, I always have to run the same import commands

$ python manage.py shell
>>> from cbapp.models import *
>>> from cbapp.services import *

I like the bpython shell and would prefer to continue to use it, but is there a way that the imports can be run prior to the shell loading so I don't have to type (or scroll to) them each time?

Dave
  • 15,639
  • 133
  • 442
  • 830
  • Does this answer your question? [Automatically import models on Django shell launch](https://stackoverflow.com/questions/4863301/automatically-import-models-on-django-shell-launch) – aberkb Nov 09 '21 at 17:25
  • IT seems like that answer relies on django-extensions, which in turn relies on using "python manage.py shell_plus". As I want to continue to use bpython, I'm not sure how that interacts with the extensions package. – Dave Nov 09 '21 at 17:39
  • [This](https://stackoverflow.com/a/11124610/6759844) might help. Tested it and works with bpython – Brian Destura Nov 12 '21 at 00:36
  • Yup, that seems to work for me as well! – Dave Nov 13 '21 at 01:27

0 Answers0