Running a script through Django admin interface button/url

I am kinda new to python and Django as well so many things still confuse me!I have my Django admin interface with a database on it! The thing i want to do now is the following: I want to be able to run a script from my Djano admin interface either by pushing a "Start" button or clicking on a URL!

Thanks for your time,any small example would be so great!

Have a nice day!

Upvotes: 0

Views: 982

Answers (2)

Mr_Spock
Mr_Spock

Reputation: 3835

Use Javascript in your template to call the view once a button is clicked, and in your view, call the script. This question's very similar to this one.

Upvotes: 1

Matt Seymour
Matt Seymour

Reputation: 9395

I would personally look at something like http://www.celeryproject.org/.

You also need to think about what would happen in the following instances.

  1. Someone else logs into the system and clicks run
  2. Is there any output? How will you handle this?
  3. User clicks refresh whilst waiting for the task to complete.
  4. Will the task complete?

Upvotes: 1

Related Questions