Code

Opened 7 years ago

Closed 5 years ago

#5610 closed (fixed)

Useful for dumpdata to be able to use a specific model

Reported by: DavidReynolds Owned by: DavidReynolds
Component: Core (Management commands) Version: master
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: UI/UX:

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

Download all attachments as: .zip

Change History (23)

comment:1 Changed 7 years ago by DavidReynolds

  • Cc david@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 7 years ago by SmileyChris

  • Component changed from Uncategorized to django-admin.py
  • Triage Stage changed from Unreviewed to Design 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 7 years ago by russellm

  • Triage Stage changed from Design decision needed to Accepted

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

comment:4 Changed 7 years ago by DavidReynolds

  • Owner changed from nobody to DavidReynolds

Changed 7 years ago by DavidReynolds

Small improvement to dumpdata

comment:5 follow-up: Changed 7 years ago by DavidReynolds

  • 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 7 years ago by russellm

  • 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 7 years ago by DavidReynolds

Fixed dumpdata as per discussion and added in tests

Changed 7 years ago by DavidReynolds

Fixed dumpdata as per discussion and added in tests

comment:7 Changed 7 years ago by DavidReynolds

  • 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 7 years ago by DavidReynolds

Docs for new features of dumpdata

Changed 7 years ago by DavidReynolds

Docs for new features of dumpdata

comment:8 Changed 7 years ago by DavidReynolds

  • 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 6 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 follow-up: Changed 6 years ago by DavidReynolds

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

Changed 6 years ago by DavidReynolds

Should now be able to be applied to trunk.

comment:11 in reply to: ↑ 10 Changed 6 years ago by DavidReynolds

Works, as of r7388.

comment:12 Changed 6 years ago by anonymous

  • Cc haavikko@… added

comment:13 Changed 6 years ago by DavidReynolds

  • Keywords feature added

Changed 6 years ago by DavidReynolds

Updated to work against latest trunk

comment:14 Changed 6 years ago by DavidReynolds

Updated to work against r9646

comment:15 Changed 5 years ago by anonymous

  • Cc oliver@… added

comment:16 Changed 5 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.