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
  • 23,545
  • 19
  • 104
  • 143

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
  • 40,868
  • 9
  • 92
  • 93
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
user1309663
  • 105
  • 7
0

Use Celery

Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284