Hello!

I have a table with Cars where are makes and models in one place. Make Models

Audi A8

Audi R8

Audi A6

BMW X5

BMW 535

I want to create a simple request for get Makes list grouped by Make.

I tried make = Car.objects.values('make').annotate(Count('id')) but I has an error 'dict' object has no attribute '_meta'

asked 19 Jul '13, 07:00

pavolve's gravatar image

pavolve
1
accept rate: 0%


SOLVED

make = Car.objects.values('make').annotate(Count('id'))

data = json.dumps(list(make))

return HttpResponse(data, mimetype='application/json')

link

answered 19 Jul '13, 08:00

pavolve's gravatar image

pavolve
1
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×1
×1
×1

Asked: 19 Jul '13, 07:00

Seen: 421 times

Last updated: 19 Jul '13, 08:00

Related questions

powered by OSQA