[Answered ]-How to run a file that uses django models (large block of code) in Pycharm

1๐Ÿ‘

โœ…

If your site loads, you should put the import the models into one of your Django views.
In a view you can do whatever you like with the models.

๐Ÿ‘คUku Loskit

1๐Ÿ‘

This snippet named Command Line Script Launcher may help you,

This snippet allows you execute arbitrary Python scripts from the command line
with the context of a given project:

python manage.py execfile /path/to/some/script.py

The doc of Django tells you how to extend manage.py commands

๐Ÿ‘คiMom0

0๐Ÿ‘

You can right click any python file in pycharm and run it, though executing a script file self contained, you might want to add the main trick:

if __name__ == "__main__":
   do_stuff()

Leave a comment