Automatically import models on Django shell launch

后端 未结 2 786
庸人自扰
庸人自扰 2021-01-30 17:00

I\'m tired of typing from account_import.models import ImportFile every time I open my Django shell. Is there a way to automatically run this command whenever I fir

2条回答
  •  忘了有多久
    2021-01-30 17:55

    install django-extensions, one of the commands it features (shell_plus) is providing the context for your models. https://github.com/django-extensions/django-extensions

    So, instead of ./manage.py shell you can use ./manage.py shell_plus so that everything is imported.

提交回复
热议问题