есть модель (часть model.py)
from django.db import models
from django.contrib.auth.models import User
class Publisher(models.Model):
name = models.CharField(max_length=30, verbose_name='Название')
address = models.CharField(max_length=50, verbose_name='Адрес')
city = models.CharField(max_length=60, verbose_name='Город')
state_province = models.CharField(max_length=30, \
verbose_name='Область')
country = models.CharField(max_length=50, \
verbose_name='Государство')
#website = models.URLField(verbose_name='Адрес сайта')
class Admin:
pass
def __unicode__(self):
return self.name
class Meta:
ordering = ['name']
class Author(models.Model):
salutation = models.CharField(max_length=10)
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=40)
email = models.EmailField(blank=True, verbose_name='e-mail')
#headshot = models.ImageField(upload_to='/tmp')
class Admin:
pass
def __unicode__(self):
return '%s %s' % (self.first_name, self.last_name)
class Book(models.Model):
title = models.CharField(max_length=100, verbose_name='Название')
authors = models.ManyToManyField(Author, verbose_name='Автор')
publisher = models.ForeignKey(Publisher, verbose_name='Издательство')
pages = models.IntegerField()
price = models.DecimalField(max_digits=10, decimal_places=2)
rating = models.FloatField()
publication_date = models.DateField(blank=True, null=True,\
verbose_name='Дата издания')
class Admin:
pass
def __unicode__(self):
return self.title
class OrderDetail (models.Model):
title = models.CharField(max_length=100, verbose_name='Заявка')
date_order = models.DateField(blank=True, null=True, \
verbose_name='Дата заказа')
class Admin:
pass
def __unicode__(self):
return self.title
class Order(models.Model):
book = models.ForeignKey(Book, verbose_name='Книга')
count = models.PositiveIntegerField(verbose_name='Кол-во')
title = models.ForeignKey(OrderDetail, verbose_name='Название заказа')
user = models.ForeignKey(User)
class Admin:
pass
def __unicode__(self):
return u'%s' % self.book
def order_edit(request, order_id):
print "author_add %s"%order_id
if order_id:
order_detail = get_object_or_404(OrderDetail, pk=order_id)
user = get_object_or_404(User, pk = request.user.id)#текущий пользователь
books = order_detail.order_set.filter(user = user).order_by('book')
q = books.aggregate(itogo=Sum('count'))
book_itogo = books.values('book').annotate(count=Sum('count'))
return render_to_response('books/books_list.html', {'books': books, \
'count_book': q['itogo'], 'book_itogo': book_itogo })
где
book - Book.id книги
count - кол-во книг я заявке
Подскажите как добавить в эту переменную название книги , т.е. Book.title?
чтобы получить что то типа
P.S. всем спасибо за любые предложения