How to detect if script ran from Django or command prompt?
Explicit is better than implicit. Wrap your interactivity in a function that's called only if the __name__ == "__main__" part was executed. From the django parts, just use it as a library. Most ways of doing these kinds of checks are semi-magical and hence flaky.
I have a Python script that pauses for user input (using raw_input, recently I created a Django web UI for this script. Now when I execute the script via Django is pauses as it's waiting for input in the backend. 
How can I determine if the script was ran from Django or terminal/cmd/etc? I don't want to maintain 2 streams of code, one for web and another one for terminal.