#7479 closed (duplicate)
Improve dictionary (dict()) support in QuerySets
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Validators | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Being a happy-dictionary-user I would love it if Django gave them more support. Two opportunities spring into mind:
- Model.objects.filter(id=1).values() does not support many-to-many fields. I feel like it should do so and return their ids as a list, like in: 'key': [1, 2, 3] . Because many-to-many fields are in the declaration of the model, and in the .filter()-results, I believe they should be represented in the .values()-dictionary as well.
- I really miss .values() in Model.objects.get(id=1), which to me seems asymmetric.
Thanks for giving this a thought. For me, dictionaries and lists are a very friendly and native way of handling data in Python. They can easily represent complex data structures while staying comprehensible. I hope they make you happy too.
Change History (5)
comment:1 by , 17 years ago
milestone: | → post-1.0 |
---|---|
Summary: | I love dictionaries → Improve dictionary (dict()) support in QuerySets |
comment:2 by , 16 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 16 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
"Django doesn't use my favourite language feature enough" isn't really a bug report.
The first part is a upe of #5768 and it isn't nearly as simple as it looks on the surface. The second part doesn't need anything done, since filter(id=1).values(...)[0]
works exactly as expected.
Going to mark as a duplicate for the first part, but we're suffering from the usual problem that when two different things are in a single ticket, no single resolution works.
comment:5 by , 15 years ago
It would be nice to document under values() that it does not work with get(), and the workaround using filter().
That's post-1.0 also set a Summary that doesn't seem like spam in the reports :)
Dunno if Design Decision of Accepted thought... we'll see.