django


Invalid distinct with django


I try to get a cars list on my Django project but i'm in trouble with ORM
class Car(models.Model):
name = models.CharField(max_length=200)
owner = models.ForeignKey(User)
With Car.objects.all() I have a list as:
- car#1, user#1
- car#1, user#2
- car#1, user#3
- car#2, user#4
- car#3, user#4
what I would like is:
- car#1
- car#2
- car#3
Then, all cars are distinct by the name, regardless of owner
I've try something like
Cars.objects.all().annotate(Count('owner', distinct=True))
but I still have all cars. Can someone help me with this point ? Documentation suggests annotate and aggregate but it's still hars to understand it.
try this
Cars.objects.values('name').distinct()

Related Links

django 1.1 permission question in template
pinax / django installation on virtual env, run on mod_wsgi
How to use Django to manage free spaces in a group of users?
The overhead of Django framework (performance impact) on Google Apps Engine
Django with mod_wsgi returns 403 error
How to implement non-database backed models in Django?
Is there a way to make a block optional in Django template
Django downloaded file is empty
Django + basic http auth
django dynamic FilePathField
Django forms request.user
django json serializer does not implement geojson
Jinja2 vs django templates with cached loader - how does performance compare?
Cross-site file upload with form validation
How many rows were deleted?
Disabling only specific 'green plus' icons on auto generated forms

Categories

HOME
service-worker
go
eclipse
checkstyle
linkedin
redux-form
jax-rs
depth
yahoo-finance
serialization
components
jsf-2.2
owl-carousel
newrelic
yandex
parameters
pyqt4
gembox-spreadsheet
azure-container-service
trac
qpython
32bit-64bit
jquery-ui-sortable
google-chrome-app
mxgraph
keytool
symfony-console
topology
charles
asp.net-core-webapi
lilypond
hta
pchart
displaytag
roundup
xunit
draft-js-plugins
froala
interbase
jasmine-node
android-maps
ms-access-2003
linked-data
panoramas
mobx
hreflang
protege4
git-rewrite-history
tex
ogc
stringtokenizer
dynamic-linq
opennms
twilio-click-to-call
qtranslate
truezip
opengl-4
android-testing
avx
java-websocket
mouseleave
cpu-cache
shinobi
polyline
materialized-path-pattern
jodd
tooleap
kango-framework
false-sharing
ascii-art
concurrentmodification
avisynth
fiware-monitoring
ess
iced-coffeescript
vacuum
teamcity-9.1
procedural-programming
webmatrix-3
deform
webfinger
cbind
kendo-dataviz
composite-component
robotlegs
mapping-by-code
ilasm
stress
agility.js
role
creole
strsep
cfwindow
lxr
skype4java
application-planning
product-management
mathematical-typesetting
cardspace

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App