On Aug 1, 11:04 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> >From the documentation:
>
> "A ValuesQuerySet is useful when you know you're only going to need
> values from a small number of the available fields and you won't need
> the functionality of a model instance object. It's more
> authors = book.authors.all().values('first_name','last_name',)
I don't think that the use of the values method is that widespread...
if you use I would suggest you to think it twice.
--~--~-~--~~~---~--~~
You received this message because you
On Jul 31, 8:15 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> def index(request):
> books = Book.objects.all().select_related()[:3]
what is doing the 3 ?
{% for book in books %}
{{ book.title }}
// I prefer use names instead of ids in urls because it's more human
Is this the *best* way to accomplish this? It seems like the author DB
query per book isn't very efficient (where it might sense to do a
JOIN) Also, if I was doing any more "levels" things would get very
complicated and bloated.
view.py:
...
def index(request):
data =
I'm using the Books, Publishers, Authors example from the
documentation (Django Book) and I'm trying to figure out how to get
related data in a list. For example, I want to print a list of books
and a list of authors for each book in my template. What do I have to
do to make the code below
5 matches
Mail list logo