Opened 17 years ago

Closed 16 years ago

Last modified 15 years ago

#7479 closed (duplicate)

Improve dictionary (dict()) support in QuerySets

Reported by: wim@… 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:

  1. 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.
  1. 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 Marc Fargas, 17 years ago

milestone: post-1.0
Summary: I love dictionariesImprove dictionary (dict()) support in QuerySets

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.

comment:2 by Eric Holscher, 16 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Malcolm Tredinnick, 16 years ago

Resolution: duplicate
Status: newclosed

"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:4 by (none), 16 years ago

milestone: post-1.0

Milestone post-1.0 deleted

comment:5 by adrian_nye, 15 years ago

It would be nice to document under values() that it does not work with get(), and the workaround using filter().

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