{{{
$ ./manage.py app1 app2 .. --format=json > dump.json
}}}
Removing the need to always do this would open up the possibility to add
verbosity during the serialization (see #22251 and a new separate ticket
for that).
Concrete proposal:
Add an option to specify a file name to write the output to (under the
current working directory), and generate one automatically when one is not
specific (e.g. "dump_20140312_1337".json/.xml").
--
Ticket URL: <https://code.djangoproject.com/ticket/22257>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted
Comment:
Yes, that makes sense.
--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:1>
* status: new => assigned
* cc: anubhav9042@… (added)
* owner: nobody => anubhav9042
--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:2>
Comment (by anubhav9042):
I have already created patch for this. But one thing I want to ask is that
whether we should keep default as `stdout` or as proposed in the ticket
some `dumpdata.json`
--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:3>
Comment (by anubhav9042):
I have yet to add tests.
https://github.com/coder9042/django/compare/ticket_22258?expand=1
--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:4>
Comment (by anubhav9042):
Added tests.
Created PR : https://github.com/django/django/pull/2465
--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:5>
Comment (by loic84):
> Add an option to specify a file name to write the output to (under the
current working directory)
Why under the current working directory? `open()` does the right thing by
default, if given a relative path, it'll use the current working
directory. The current working directory could very much be readonly, and
requiring people to `cd` to target a specific directory is not practical.
From a quick look at the patch, I think it does the right thing.
--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:6>
Comment (by Gwildor):
Replying to [comment:6 loic84]:
> > Add an option to specify a file name to write the output to (under the
current working directory)
>
> Why under the current working directory? `open()` does the right thing
by default, if given a relative path, it'll use the current working
directory. The current working directory could very much be readonly, and
requiring people to `cd` to target a specific directory is not practical.
>
> From a quick look at the patch, I think it does the right thing.
I'm sorry, this was what I meant. So you can also do `-o
../dumps/dump.json`, or something alike. Patch indeed looks good on that
matter.
About the default: I agree that defaulting to `stdout` is the way to go to
maintain backwards compatibility. The main reason I opted for generating a
filename and using that when not specific, is in the light of ticket
#22258.
--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:7>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:8>
Comment (by anubhav9042):
Replying to [comment:8 anubhav9042]:
Can you comment out your thoughts regarding #22258 on the ticket itself, I
mean if you have something in mind
--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:9>
Comment (by anubhav9042):
Replying to [comment:7 Gwildor]:
> About the default: I agree that defaulting to `stdout` is the way to go
to maintain backwards compatibility. The main reason I opted for
generating a filename and using that when not specific, is in the light of
ticket #22258.
Do you have any ideas in mind. If yes then please comment them out on
#22258 itself. I want to know exactly what you are suggesting.
--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:10>
Comment (by anubhav9042):
Replying to [comment:10 anubhav9042]:
> Replying to [comment:7 Gwildor]:
I think we can keep default as `stdout` and and for #22258, we can do the
following:
- When -o is not used, let the data be printed to `stdout`, as the data is
printing people can see it and I don't think any progress display is
required there.
- When -o will be used, then we can display progress percentage or
something like that.
--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:11>
Comment (by russellm):
If you're outputting to console, I don't see how you can display a
progress indicator. Making a progress indicator dependent on the use of -o
seems like a reasonable approach to me.
--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:12>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:13>
* needs_better_patch: 0 => 1
* stage: Ready for checkin => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:14>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"f34e8fc890d44f4f913fe812f2cdeb5666f0fa27"]:
{{{
#!CommitTicketReference repository=""
revision="f34e8fc890d44f4f913fe812f2cdeb5666f0fa27"
Fixed #22257 -- Added file output option to dumpdata command.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:15>
Comment (by Marc Tamlyn <marc.tamlyn@…>):
In [changeset:"09ab447d083558c0822acd58ab621e06c206ccba"]:
{{{
#!CommitTicketReference repository=""
revision="09ab447d083558c0822acd58ab621e06c206ccba"
Merge pull request #2465 from coder9042/ticket_22258
Fixed #22257 -- Added file output option to dumpdata command.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:16>
Comment (by Tim Graham <timograham@…>):
In [changeset:"e3c4205b79cff2be809c3698df2e9d53303b5070"]:
{{{
#!CommitTicketReference repository=""
revision="e3c4205b79cff2be809c3698df2e9d53303b5070"
flake8 and doc fixes for refs #22257.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:17>
Comment (by anubhav9042):
Thanks for that.
--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:18>
Comment (by Gwildor):
Thanks everyone for the quick implementation :)
--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:19>