djangomanage.pydumpdata

Django dumpdata doesn't write to file, generate "Bad file descriptor" error


I'm trying to dumpdata into a file, and keep getting this error:

d:\django\mysite>manage.py dumpdata > alldata.json
Traceback (most recent call last):
  File "D:\django\mysite\manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 241, in execute
    self.stdout.write(output)
IOError: [Errno 9] Bad file descriptor

I have a feeling this has something to do with codepage or unicode. Trying executing this in PowerShell, and there was no error, but the data was PRINTED to the screen and the file was empty... (as if the > sign wasn't there).

Anyone has any idea what could cause this?

Thanks in advance :)


Solution

  • If I am not wrong, you are using

    manage.py dumpdata
    

    try to use it like this

    python manage.py dumpdata
    

    It should work.

    Thanks