Opened 17 years ago

Closed 15 years ago

#5610 closed (fixed)

Useful for dumpdata to be able to use a specific model

Reported by: David Reynolds Owned by: David Reynolds
Component: Core (Management commands) Version: dev
Severity: Keywords: sprintdec01 feature
Cc: david@…, haavikko@…, oliver@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It would be useful if ./manage.py dumpdata was able to take optional model parameters for dumping a specific models data. For example:

./manage.py dumpdata product.Category 

Would output only data related to the Category model in the product application.

Attachments (7)

dumpdata-improvements.diff (1.7 KB ) - added by David Reynolds 17 years ago.
Small improvement to dumpdata
dumpdata-additions-5610.diff (5.4 KB ) - added by David Reynolds 17 years ago.
Fixed dumpdata as per discussion and added in tests
dumpdata-additions-5610.2.diff (5.4 KB ) - added by David Reynolds 17 years ago.
Fixed dumpdata as per discussion and added in tests
ukcountieslocalflavor-5523.diff (1.3 KB ) - added by David Reynolds 17 years ago.
Docs for new features of dumpdata
dumpdata-additions-docs-5610.diff (6.3 KB ) - added by David Reynolds 17 years ago.
Docs for new features of dumpdata
dumpdata-additions-trunk-5610.diff (7.1 KB ) - added by David Reynolds 16 years ago.
Should now be able to be applied to trunk.
dumpdata-addition-r9646.diff (6.1 KB ) - added by David Reynolds 16 years ago.
Updated to work against latest trunk

Download all attachments as: .zip

Change History (23)

comment:1 by David Reynolds, 17 years ago

Cc: david@… added

comment:2 by Chris Beaven, 17 years ago

Component: Uncategorizeddjango-admin.py
Triage Stage: UnreviewedDesign decision needed

I agree, that could be useful... but I'll push to a design decision. Perhaps bring this up on the django-dev group

comment:3 by Russell Keith-Magee, 17 years ago

Triage Stage: Design decision neededAccepted

Sounds good to me. It would also integrate nicely with proposal #4656.

comment:4 by David Reynolds, 17 years ago

Owner: changed from nobody to David Reynolds

by David Reynolds, 17 years ago

Attachment: dumpdata-improvements.diff added

Small improvement to dumpdata

comment:5 by David Reynolds, 17 years ago

Has patch: set

Patch adds the functionality, not sure how good the patch is.

Also, it has the ability for you to be able to dump overlapping data, which I'm not certain is useful or not. For example if you did:

./manage.py dumpdata product.Category product

You'd get 2 copies of product.Category

I'm sure I can fix this, but just wondered what people's opinions were on whether it needs fixing or not.

in reply to:  5 comment:6 by Russell Keith-Magee, 17 years ago

Needs documentation: set
Needs tests: set
Patch needs improvement: set

Replying to DavidReynolds:

I'm sure I can fix this, but just wondered what people's opinions were on whether it needs fixing or not.

Yes, it does :-)

The patch looks essentially ok, except that it needs docs and tests. As for how to fix the problem you describe - I would suggest collecting the serialization candidates as a dictionary {app: [model list]}; if you specify just the app name, the model list is set to None. Each argument you process checks the existing contents of the dictionary - any existing None entry means you don't have to add an individual model entry, and if you process an app but there is already a model list, you can replace the list with None. (I hope that makes some sort of sense)

by David Reynolds, 17 years ago

Fixed dumpdata as per discussion and added in tests

by David Reynolds, 17 years ago

Fixed dumpdata as per discussion and added in tests

comment:7 by David Reynolds, 17 years ago

Keywords: sprintdec01 added

Please ignore the second patch, I got my diff the wrong way around. Can someone advise on if the tests are ok?

by David Reynolds, 17 years ago

Docs for new features of dumpdata

by David Reynolds, 17 years ago

Docs for new features of dumpdata

comment:8 by David Reynolds, 17 years ago

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

It's not my day today.

Please ignore the wrong patch I added. The latest patch now has docs and tests in it.

comment:9 by haavikko@…, 17 years ago

Thanks for the very useful patch, this was just the functionality I needed.
Problem: starting R6922, I no longer can apply dumpdata-additions-docs-5610.diff against trunk.

comment:10 by David Reynolds, 16 years ago

Ok, I'll try and fix it for more recent trunk.

by David Reynolds, 16 years ago

Should now be able to be applied to trunk.

in reply to:  10 comment:11 by David Reynolds, 16 years ago

Works, as of r7388.

comment:12 by anonymous, 16 years ago

Cc: haavikko@… added

comment:13 by David Reynolds, 16 years ago

Keywords: feature added

by David Reynolds, 16 years ago

Updated to work against latest trunk

comment:14 by David Reynolds, 16 years ago

Updated to work against r9646

comment:15 by anonymous, 15 years ago

Cc: oliver@… added

comment:16 by Russell Keith-Magee, 15 years ago

Resolution: fixed
Status: newclosed

(In [9921]) Fixed #5610 -- Added the ability for dumpdata to take individual model names, as well as entire applications. Thanks to David Reynolds for his work on this patch.

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