[Answered ]-How to Running external command (Django) for overriding files in server?

1👍

You can’t change your models.py while the webserver is running, because models (and other python code) are only loaded at server startup.

1👍

There are 2 parts in you question:
a) you want the shell to do something when view function is called. I have alarm beeping already.
b) you want to load new model. It won’t gonna happen. You must reload to have new code loaded in (model introspected, etc.). Probably you use runserver command, take a look on Django autoreloader code: https://github.com/django/django/blob/master/django/utils/autoreload.py

It tracks files listed by gen_filenames() and reload when something was changed. You model was not listed so the change to the code will not be reflected.

I would touch something or remove .pyc files to force the reloader.

Leave a comment