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)
Change History (23)
comment:1 Changed 16 years ago by
Cc: | david@… added |
---|
comment:2 Changed 16 years ago by
Component: | Uncategorized → django-admin.py |
---|---|
Triage Stage: | Unreviewed → Design decision needed |
comment:3 Changed 16 years ago by
Triage Stage: | Design decision needed → Accepted |
---|
Sounds good to me. It would also integrate nicely with proposal #4656.
comment:4 Changed 16 years ago by
Owner: | changed from nobody to David Reynolds |
---|
comment:5 follow-up: 6 Changed 16 years ago by
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 Changed 16 years ago by
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
Attachment: | dumpdata-additions-5610.diff added |
---|
Fixed dumpdata as per discussion and added in tests
Changed 16 years ago by
Attachment: | dumpdata-additions-5610.2.diff added |
---|
Fixed dumpdata as per discussion and added in tests
comment:7 Changed 16 years ago by
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
Attachment: | ukcountieslocalflavor-5523.diff added |
---|
Docs for new features of dumpdata
Changed 16 years ago by
Attachment: | dumpdata-additions-docs-5610.diff added |
---|
Docs for new features of dumpdata
comment:8 Changed 16 years ago by
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
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.
Changed 15 years ago by
Attachment: | dumpdata-additions-trunk-5610.diff added |
---|
Should now be able to be applied to trunk.
comment:12 Changed 15 years ago by
Cc: | haavikko@… added |
---|
comment:13 Changed 15 years ago by
Keywords: | feature added |
---|
Changed 15 years ago by
Attachment: | dumpdata-addition-r9646.diff added |
---|
Updated to work against latest trunk
comment:15 Changed 15 years ago by
Cc: | oliver@… added |
---|
comment:16 Changed 15 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
I agree, that could be useful... but I'll push to a design decision. Perhaps bring this up on the django-dev group