I want to write a very small Django application in a single file, requiring all the appropriate modules and stuff, and then be able to run that as a normal Python script, li
You might want to consider Simon Willison's library:
From the readme:
djng is a micro-framework that depends on a macro-framework (Django).
My definition of a micro-framework: something that lets you create an entire Python web application in a single module:
import djng def index(request): return djng.Response('Hello, world') if __name__ == '__main__': djng.serve(index, '0.0.0.0', 8888)[...]