On Tue, Jun 22, 2010 at 4:08 AM, maxweld <da...@maxwell.uk.net> wrote: > I am working with my virtual hosting provider to enable him support > Django. I have used him for ages, and having converted myself to > Django would like to help establish another hosting provider with > support for Django. > > I have a configuration for his servers and virtual hosting environment > that works well, enabling the application to be developed on a > development server using Django's 'runserver', and then transferred to > the virtual hosting environment where the production service would > run. > > I now need to work out how best to execute the various commands > provided by django-admin.py. The hosted environment provides no shell > access, only FTP to copy files to the site and phpMyAdmin to manage > the database tables. This is basically a security feature.
There is a way to do this, but for some reason it doesn't appear to be documented (which is itself a bug that should be logged). However, the technique is mentioned in passing in the 1.0 porting guide: http://docs.djangoproject.com/en/dev/releases/1.0-porting-guide/#running-management-commands-from-your-code Ignore the old-style syntax, and just look at new-style management.call_command syntax. That allows you to call any management command you want, with whatever command-line arguments you want. > I would like to be able to execute django-admin.py through a web > interface, ideally capturing the output and displaying it back to the > user. Has this ever been tried before? Does anybody know of a package > doing this? Am I crazy? The output capture is the only difficult part; historically, admin commands have directly written out stdout. You can work around this with some monkeypatching of sys.stdout/stderr -- it's not pretty, but it does work. The good news is that in trunk, we've started to rectify this. We've added self.stdout and self.stderr to management commands; these act as mirrors of sys.stdout and sys.stderr by default, but you can programatically set them to be any other stream you want. See http://docs.djangoproject.com/en/dev/howto/custom-management-commands/ for usage, and the fixtures modeltest for an example of usage (and, for that matter, of an example of usage of call_command). Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.