Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pycharm - autoload models in Django console

Is there a way to autoload models in the pycharm django console (in a similar way to how django-extensions shell_plus works)?

like image 982
Yunti Avatar asked Dec 05 '22 19:12

Yunti


1 Answers

In pycharm settings, django console settings you can have a starting script:

This will automatically load the django models, like shell_plus:

import sys
import django
django.setup()

from django.apps import apps

for _class in apps.get_models():
    globals()[_class.__name__] = _class
like image 154
Yunti Avatar answered Dec 19 '22 07:12

Yunti