Whoami
Whoami

Reputation: 14418

Cron Job that access django Models

What i have done?

I have written a small application in django with few models with sqlite3 as backend. Now i want to write a python code that clears the database elements based on certain condition.

Question:

How can i achieve the above requirement?

Upvotes: 0

Views: 1057

Answers (1)

Ludwik Trammer
Ludwik Trammer

Reputation: 25032

I think the cleanest way to do this is to write your own django-admin command.

You can then run the command using manage.py:

python manage.py your_command

Having a command that can be run in shell, you can easily put in into your crontab. Optionally django-admin commands can receive command line arguments, if needed.

Upvotes: 5

Related Questions