#19115 closed Cleanup/optimization (fixed)
dumpdata should take option to output to named file
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | dumpdata management command |
Cc: | d1fffuz0r@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
If the dumpdata management command could output to a named file, it would make it a lot easier to invoke dumpdata from other management commands via call_command.
Attachments (4)
Change History (16)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Component: | Core (Management commands) → Documentation |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | New feature → Cleanup/optimization |
by , 12 years ago
Attachment: | 19115.patch added |
---|
comment:3 by , 12 years ago
Cc: | added |
---|---|
Has patch: | set |
Version: | 1.4 → master |
added new optional parameter to dumpdata command, for save data to file
comment:4 by , 12 years ago
Patch needs improvement: | set |
---|
This ticket was accepted on the base that we should document the stdout usage of call_command, which is also useful for all other commands. Not to add another option to dumpdata.
by , 12 years ago
Attachment: | 19115.2.patch added |
---|
comment:6 by , 12 years ago
Thanks for your efforts. As the stdout option is valid for all commands, I'd rather add a paragraph (Output redirection) in the section https://docs.djangoproject.com/en/dev/ref/django-admin/#running-management-commands-from-your-code
Then you can just add a reference to it from the dumpdata
section.
by , 12 years ago
Attachment: | 19115.3.patch added |
---|
by , 12 years ago
Attachment: | 19115.4.patch added |
---|
comment:8 by , 12 years ago
After some thoughts, here's how I'd like to document it. I don't think it's worth adding the note to the dumpdata command section, as we should then specify it also for all other commands which output data. We can count on people trying to output data with a management command to look after the call_command
section.
comment:9 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
follow-up: 12 comment:11 by , 11 years ago
how do we use this ?
./manage dumpdata --stdout=file.json ?
comment:12 by , 11 years ago
Replying to maa@…:
how do we use this ?
./manage dumpdata --stdout=file.json ?
This ticket tracker is not the best place to ask questions like this. You should use our support channels instead [1].
As for your question, since the command outputs its result, you can use your shell's output redirection feature:
./manage dumpdata > the_name_of_the_file.json
[1] https://code.djangoproject.com/wiki/TicketClosingReasons/UseSupportChannels
We could document you can achieve this by passing a file like object as the
stdout
kwarg ofcall_command
.This looks quite easy to me.