2

I have a Django site that is up and running. I need to add a feature to call wget in response to a user action. How should I do this from the Django application?

Alexis
  • 19,151
  • 17
  • 91
  • 134

3 Answers3

5

Since Django is written in Python you can use Python's subprocess module to call wget in one of your views. However, if you merely want to download a file with wget (and not use one of its advanced features), you can emulate its behavior more easily with urllib2.

Uku Loskit
  • 37,259
  • 9
  • 85
  • 88
2

Is there a reason why you're resorting to a unix command, rather than using something like urllib2?

If there is, you can always use this within your view:

from subprocess import call
call(["wget", "http://myurl.com"])

Here's a pretty comprehensive thread on the matter:

Calling an external command in Python

Community
  • 1
  • 1
0

Use Celery

Burhan Khalid
  • 152,028
  • 17
  • 215
  • 255