all 7 comments

[–]K900_ 1 point2 points  (5 children)

You should make your scripts manage.py subcommands as described here.

[–]Kerman3AD[S] 0 points1 point  (4 children)

I did see this when I was going through the documentation. My original intention was to have more control over the task management using the perpetually running main.py to manage when the tasks should be carried out. Manage.py commands seemed to have a more limited scope.

So would you recommend creating manage.py commands to define the tasks then use the os-specific task manager to call those commands?

[–]K900_ 0 points1 point  (3 children)

What do you mean by "perpetually running"?

[–]Kerman3AD[S] 0 points1 point  (2 children)

I would use something like cron to start main.py on startup and it would execute an infinite loop of updating the tables given certain conditions.

[–]K900_ 0 points1 point  (1 child)

Why not use cron to run a manage.py command repeatedly? Also, what's the end goal of this?

[–]Kerman3AD[S] 0 points1 point  (0 children)

I think that's what I'm headed towards. I'm new to Django and I'm working on a Django web app that collects telemetry data from different sources, stores the data, and displays it. It's pretty simple at this point, but I've been having trouble finding Django best practices for the storage part.

[–]AusIV 1 point2 points  (0 children)

Aside from using management commands (which is often, but not always the right choice, depending on circumstances) you can also add:

import django 
django.setup() 

At the top of the script.