Wednesday, November 30, 2011

Re: A view associated with a lot of urls

> Well I agree that if the category doesn't exist he will get a 404. But
> if the Category exists and there are no items in the 'table', it will
> not be empty, it will also raise a 404 too. That's why I wrote :
>
>> However with that, there is no way for example to make a difference
>> between "there is no items in this category" and "this category
>> doesn't exist" !

No. with the line below items will be empty ant not 404.

items= get_object_or_404(Category,name=category).items().filter(name=item)

or items without the brackets. (not sure about the syntax at the moment)

The above is the same as:

# This could produce 404
category = get_object_or_404(Category,name=category)

# This will result in an empty queryset and not 404
items = category.items().filter(name=item)

It is also obvious that the last line does not produce 404 since 404 is HTML related and the line above is a DB query which at most should result in something empty.

I just saw your answer about using NoSQL. Sorry, forgot about that.

In that case I cannot help you.

Good Luck

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment