#26144 closed Cleanup/optimization (fixed)
Warn if a proxy model is an argument to dumpdata
Reported by: | Kiss György | Owned by: | nobody |
---|---|---|---|
Component: | Core (Management commands) | Version: | 1.9 |
Severity: | Normal | Keywords: | dumpdata, models |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
When someone runs manage.py dumpdata
on a proxy model, it just gives an empty list output. The command at least should warn that the data cannot be dumped.
Change History (9)
comment:1 by , 9 years ago
Has patch: | set |
---|---|
Patch needs improvement: | set |
Summary: | Dumping a proxy model does nothing → Warn if a proxy model is an argument to dumpdata |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 9 years ago
What about warn and add an --ignore-warnings
option to the dumpdata command?
What happened me that I lost data when I dumped my "core" app, assuming it would dump everything.
follow-up: 4 comment:3 by , 9 years ago
I don't see an advantage of burdening everyone that uses proxy models with warnings for normal dumpdata
usage. If we extended the warning to if an app is specified like dumpdata app
would that have helped?
The behavior seems intuitive to me, however, the dumpdata documentation doesn't seem to mention it, so that's a candidate for an update as well.
comment:4 by , 9 years ago
Replying to timgraham:
I don't see an advantage of burdening everyone that uses proxy models with warnings for normal
dumpdata
usage. If we extended the warning to if an app is specified likedumpdata app
would that have helped?
Sure, because if you dumpdata without parameters, everything will be dumped. Absolutely not necessary to warn in that case at all.
It would be just nice if it would warn that you "might" lose some data if somebody is unobservant like me :)
comment:5 by , 9 years ago
What about issuing a warning if a proxy model is included but not the concrete model it's proxying?
Since dumpdata
uses _base_manager
the concrete model instances returned should be the same as what the proxy instances would have been.
comment:7 by , 9 years ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
Looks good, pending some cosmetic edits.
Looking at the proposed pull request, I think it would be fine to warn if the proxy model is specified in the command args, e.g.
dumpdata app.ProxyModel
, but otherwise I think warnings would clutter the output.