[Django] #22257: Write to specified file for dumpdata

10 views
Skip to first unread message

Django

unread,
Mar 12, 2014, 2:51:37 PM3/12/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
--------------------------------------------+--------------------
Reporter: Gwildor | Owner: nobody
Type: New feature | Status: new
Component: Core (Management commands) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------------+--------------------
In response of ticket #22251, I'm opening this as a separate issue like
requested. You can read the need for this option there, but basically it
removes the current need and practice of redirecting the output of the
command to a file, which is often done like this:

{{{
$ ./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.

Django

unread,
Mar 20, 2014, 2:32:09 PM3/20/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
-------------------------------------+-------------------------------------

Reporter: Gwildor | Owner: nobody
Type: New feature | Status: new
Component: Core (Management | Version: master
commands) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* 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>

Django

unread,
Mar 23, 2014, 1:42:20 AM3/23/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
-------------------------------------+-------------------------------------
Reporter: Gwildor | Owner:
Type: New feature | anubhav9042
Component: Core (Management | Status: assigned
commands) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by anubhav9042):

* status: new => assigned
* cc: anubhav9042@… (added)
* owner: nobody => anubhav9042


--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:2>

Django

unread,
Mar 23, 2014, 1:44:20 AM3/23/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
-------------------------------------+-------------------------------------
Reporter: Gwildor | Owner:
Type: New feature | anubhav9042
Component: Core (Management | Status: assigned
commands) | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Mar 23, 2014, 1:46:29 AM3/23/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
-------------------------------------+-------------------------------------
Reporter: Gwildor | Owner:
Type: New feature | anubhav9042
Component: Core (Management | Status: assigned
commands) | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Mar 23, 2014, 2:56:20 AM3/23/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
-------------------------------------+-------------------------------------
Reporter: Gwildor | Owner:
Type: New feature | anubhav9042
Component: Core (Management | Status: assigned
commands) | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by anubhav9042):

Added tests.
Created PR : https://github.com/django/django/pull/2465

--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:5>

Django

unread,
Mar 23, 2014, 2:57:16 AM3/23/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
-------------------------------------+-------------------------------------
Reporter: Gwildor | Owner:
Type: New feature | anubhav9042
Component: Core (Management | Status: assigned
commands) | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Mar 23, 2014, 7:03:24 AM3/23/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
-------------------------------------+-------------------------------------
Reporter: Gwildor | Owner:
Type: New feature | anubhav9042
Component: Core (Management | Status: assigned
commands) | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Mar 23, 2014, 12:21:35 PM3/23/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
-------------------------------------+-------------------------------------
Reporter: Gwildor | Owner:
Type: New feature | anubhav9042
Component: Core (Management | Status: assigned
commands) | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by anubhav9042):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:8>

Django

unread,
Mar 23, 2014, 12:33:34 PM3/23/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
-------------------------------------+-------------------------------------
Reporter: Gwildor | Owner:
Type: New feature | anubhav9042
Component: Core (Management | Status: assigned
commands) | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Mar 23, 2014, 12:36:43 PM3/23/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
-------------------------------------+-------------------------------------
Reporter: Gwildor | Owner:
Type: New feature | anubhav9042
Component: Core (Management | Status: assigned
commands) | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Mar 23, 2014, 12:42:56 PM3/23/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
-------------------------------------+-------------------------------------
Reporter: Gwildor | Owner:
Type: New feature | anubhav9042
Component: Core (Management | Status: assigned
commands) | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Mar 23, 2014, 8:44:23 PM3/23/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
-------------------------------------+-------------------------------------
Reporter: Gwildor | Owner:
Type: New feature | anubhav9042
Component: Core (Management | Status: assigned
commands) | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Mar 24, 2014, 5:21:40 AM3/24/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
-------------------------------------+-------------------------------------
Reporter: Gwildor | Owner:
Type: New feature | anubhav9042
Component: Core (Management | Status: assigned
commands) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
Has patch: 1 | checkin
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by mjtamlyn):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:13>

Django

unread,
Mar 24, 2014, 5:03:41 PM3/24/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
-------------------------------------+-------------------------------------
Reporter: Gwildor | Owner:
Type: New feature | anubhav9042
Component: Core (Management | Status: assigned
commands) | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by mjtamlyn):

* needs_better_patch: 0 => 1
* stage: Ready for checkin => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:14>

Django

unread,
Mar 25, 2014, 7:42:20 AM3/25/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
-------------------------------------+-------------------------------------
Reporter: Gwildor | Owner:
Type: New feature | anubhav9042
Component: Core (Management | Status: closed
commands) | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Anubhav Joshi <anubhav9042@…>):

* 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>

Django

unread,
Mar 25, 2014, 7:42:21 AM3/25/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
-------------------------------------+-------------------------------------
Reporter: Gwildor | Owner:
Type: New feature | anubhav9042
Component: Core (Management | Status: closed
commands) | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Mar 25, 2014, 9:45:21 AM3/25/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
-------------------------------------+-------------------------------------
Reporter: Gwildor | Owner:
Type: New feature | anubhav9042
Component: Core (Management | Status: closed
commands) | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Mar 29, 2014, 2:46:34 PM3/29/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
-------------------------------------+-------------------------------------
Reporter: Gwildor | Owner:
Type: New feature | anubhav9042
Component: Core (Management | Status: closed
commands) | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by anubhav9042):

Thanks for that.

--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:18>

Django

unread,
Mar 29, 2014, 5:32:25 PM3/29/14
to django-...@googlegroups.com
#22257: Write to specified file for dumpdata
-------------------------------------+-------------------------------------
Reporter: Gwildor | Owner:
Type: New feature | anubhav9042
Component: Core (Management | Status: closed
commands) | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Gwildor):

Thanks everyone for the quick implementation :)

--
Ticket URL: <https://code.djangoproject.com/ticket/22257#comment:19>

Reply all
Reply to author
Forward
0 new messages