Opened 2 years ago

Closed 2 years ago

#33847 closed Bug (invalid)

`dumpdata` commands fails when invoked programmatically (but runs fine from commandline)

Reported by: Frederic Brodbeck Owned by: nobody
Component: Core (Management commands) Version: 3.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I want to run django's dumpdata command programmatically, however

from django.core.management import call_command
call_command('dumpdata', 'asdf', indent=2, output=filePath)

fails with Unable to serialize database: 'ascii' codec can't encode character '\xdf' in position 83: ordinal not in range(128).

running python3 manage.py dumpdata --indent=2 --output=dump.json.gz asdf from the command line works fine though!

why won't it work with call_command()?


  • python version: 3.6.9
  • django version: 3.2.13
  • $LANG is set to en_US.UTF-8
  • $LC_ALL is set to en_US.UTF-8
  • $LC_CTYPE is set to UTF-8

Change History (1)

comment:1 by Carlton Gibson, 2 years ago

Resolution: invalid
Status: newclosed

This is almost certainly a locale issue — are those $LANG vars really being set in a script environment? 🤔
See (e.g.) #15017, #20572, #32439 (and links therein) for some historical issues in this area.

You'll need to debug yourself, or provide a minimal test project that reproduces the issue.
Happy to reopen to look if you can provide such.

Note: See TracTickets for help on using tickets.
Back to Top