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

Download all attachments as: .zip

Change History (23)

comment:1 Changed 16 years ago by David Reynolds

Cc: david@… added

comment:2 Changed 16 years ago by Chris Beaven

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 Changed 16 years ago by Russell Keith-Magee

Triage Stage: Design decision neededAccepted

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

comment:4 Changed 16 years ago by David Reynolds

Owner: changed from nobody to David Reynolds

Changed 16 years ago by David Reynolds

Attachment: dumpdata-improvements.diff added

Small improvement to dumpdata

comment:5 Changed 16 years ago by David Reynolds

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.

comment:6 in reply to:  5 Changed 16 years ago by Russell Keith-Magee

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)

Changed 16 years ago by David Reynolds

Fixed dumpdata as per discussion and added in tests

Changed 16 years ago by David Reynolds

Fixed dumpdata as per discussion and added in tests

comment:7 Changed 16 years ago by David Reynolds

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?

Changed 16 years ago by David Reynolds

Docs for new features of dumpdata

Changed 16 years ago by David Reynolds

Docs for new features of dumpdata

comment:8 Changed 16 years ago by David Reynolds

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 Changed 16 years ago by haavikko@…

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 Changed 16 years ago by David Reynolds

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

Changed 15 years ago by David Reynolds

Should now be able to be applied to trunk.

comment:11 in reply to:  10 Changed 15 years ago by David Reynolds

Works, as of r7388.

comment:12 Changed 15 years ago by anonymous

Cc: haavikko@… added

comment:13 Changed 15 years ago by David Reynolds

Keywords: feature added

Changed 15 years ago by David Reynolds

Updated to work against latest trunk

comment:14 Changed 15 years ago by David Reynolds

Updated to work against r9646

comment:15 Changed 15 years ago by anonymous

Cc: oliver@… added

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

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