No, that wouldn't work because Category looks like a var on Novel, not
a model in it's own right.

Novels.objects.filter(category="comedy") is how to get a distinct category.

To get the list of categories used, use distinct for a quick hack -
something like:

Novel.objects.order_by('category').distinct('category')

Cheers
L.

On 24 May 2014 12:33, Jonathan Querubina <john.chro...@gmail.com> wrote:
> Hi dota and java,
>
> If your model for the categories is Category, you would use:
>
> Category.objects.all()
>
> Sent from my iPad
>
> On May 23, 2014, at 23:23, dotaandj...@gmail.com wrote:
>
> i can't find a more effective method from the documentation,but thank you
> all the same
>
> 在 2014年5月23日星期五UTC+8下午11时12分13秒,sacrac写道:
>>
>> Hi, you read the documentation?
>> https://docs.djangoproject.com/en/1.6/ref/models/querysets/
>>
>>
>> On Fri, May 23, 2014 at 6:36 AM, <dotaa...@gmail.com> wrote:
>>>
>>> In Models i declare Novel: name,category
>>> table structure:
>>> ---------------------------------------
>>> id    |   name   |    category
>>> ---------------------------------------
>>>
>>>
>>> now i want to get all category,but i have no idea,who can help me?
>>>
>>> my english is poor,please don't joke me
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/27a36b70-7f89-4a02-97d5-a5e27789068e%40googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/17e7d1fb-b004-4141-b30b-7578fcf72c2e%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4800DB60-6DD7-43A1-9B1F-2E518C56242F%40gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 
The idea of anathematising all of a person’s good works because of
something else they said or did is just as alien and repellent to us
as our reaction is to someone who wishes Hacker News would die because
Paul Graham is kind of a dick sometimes. ... Sergey Bratus points out
that keeping works by “ideologically impure” persons out of public
view was instrumental to Soviet systems of social control. And as
@puellavulnerata acutely observes, a culture that encourages judging
people unilaterally, rather than judging their actions in context, is
one that allows socially-adept hierarchy climbers to decontextualise
their own self-serving cruelties as “necessary for the cause” and
stage witchcraft trials against the weirdoes on the margin.
-----------------------------------------------------------------------------------------------------------
https://medium.com/p/31895b01e68c

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGBeqiOYZwFrV%2Bi8CcnYOu4BWjQVMn82PUmtvEW6tEb5UA%3Da9A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to