[Answered ]-Django: Having arbitrary file access models

2👍

I would like “fileToDoThings.py” do things with my models

To do arbitrary operations from the command line, write a new Django management command.

You write your ‘lorem_ipsum.py’ module within a particular app, placing it a fooapp/management/commands/lorem_ipsum.py. Write it to define a command as per the documentation above.

Then you can invoke that as a management command: python3 -m manage lorem_ipsum.


Am I missing something really simple?

Simple, yes; obvious, no.

Django is a framework, not a library. The difference has been characterised by saying that with a library, you write code that calls the library; with a framework, you write code that gets called by the framework.

In other words, the way to get things done in a framework is to find the places where your code fits, and write it to fit those places.

0👍

👤dd42

Leave a comment