Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#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 Tim Graham, 9 years ago

Has patch: set
Patch needs improvement: set
Summary: Dumping a proxy model does nothingWarn if a proxy model is an argument to dumpdata
Triage Stage: UnreviewedAccepted

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.

comment:2 by Kiss György, 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.

Last edited 9 years ago by Tim Graham (previous) (diff)

comment:3 by Tim Graham, 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.

in reply to:  3 comment:4 by Kiss György, 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 like dumpdata 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 Simon Charette, 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:6 by Tim Graham, 9 years ago

If not too complicated, sounds good to me.

comment:7 by Tim Graham, 9 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

Looks good, pending some cosmetic edits.

comment:8 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: newclosed

In 0edb8a1:

Fixed #26144 -- Warned when dumping proxy model without concrete parent.

comment:9 by Simon Charette <charette.s@…>, 9 years ago

In 27531451:

Refs #26144 -- Used proxy_for_model instead of mro inspection.

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