Referring to, executing management commands from code,
Is their a way to call this command execution code from the django admin interface?
I've a custom command to do some periodic update of database which has been scheduled as cron. The cron is working fine. I need to update the database manually from the admin interface whenever needed.
update: you can run any management command simply by calling the function
call_command('compilemessages')
from anywhere within your python code. Note: this obviously is a blocking process from the caller's perspective. With the ajax example below you can have a form of non-blocking/asynchronous user experience. Depending on the backend implementation you can take this isolation level further.Example:
If the task is bound to the object currently viewed in the admin, a nice way might be to implement an extra view called by an ajax script when clicking a button. The extra view could optionally be wrapped as a celery task, e.g.
models.py
admin.py
admin_tasks.js
If you're trying to initiate an unbound task you could just override a template element or add some html.