得到代码/
context['menu_shop'] = ShopMenu.objects.filter(shop=shop_id)
型号:
class ShopMenu(models.Model):
name = models.CharField(max_length=255, verbose_name=u'Название раздела')
shop = models.ForeignKey(Shop, verbose_name=u'Заведение',
related_name="menushop")
class ShopSubMenu(models.Model):
name = models.CharField(max_length=255, verbose_name=u'Название подраздела')
shopmenu = models.ForeignKey(ShopMenu, verbose_name=u'Надкаталог',
related_name="submenushop")
dish = models.ManyToManyField(Dish, blank=True)
def __unicode__(self):
return u'%s' % (self.name)
class Dish........
什么时候创建垂直分页符,但无法理解如何获得Dish限制
那么我如何通过LIMIT FROM ShopMenu
获得Dish?
\模板:
{% for menu in menu_shop %}
<h2 class="h1_title">{{ menu }}</h2>
<div class="row row-catalog">
{% for submenu in menu.submenushop.all %}
{% for dish in submenu.dish.all %}
class Dish(models.Model):
criterion_list = (
('1', u'Блюдо без мяса'),
('2', u'Острое блюдо'),
('3', u'Здоровое питание'),
('4', u'Акция'),
('5', u'Блюдо сезона'),
('6', u'Блюдо дня'),
('7', u'Ваше любимое блюдо'),
('8', u'Еда за баллы'))
name = models.CharField(max_length=255, verbose_name=u'Название')
criterion_first = models.CharField(max_length=255, blank=True,
null=True,
choices=criterion_list,
verbose_name=u'Критерий 1')
criterion_second = models.CharField(max_length=255, blank=True,
null=True,
choices=criterion_list,
verbose_name=u'Критерий 2')
price = models.FloatField(max_length=255, verbose_name=u'Цена',
default=0, blank=True, null=True)
weight = models.CharField(max_length=255, verbose_name=u'Вес',
blank=True, null=True)
description = models.TextField(max_length=3000,
verbose_name=u'Описание',
blank=True, null=True)
points_price = models.IntegerField(verbose_name=u'Цена за баллы',
default=0, blank=True, null=True)
is_points = models.BooleanField(verbose_name=u'Еда за баллы',
default=False, blank=True)
is_recom = models.BooleanField(verbose_name=u'В рекомендациях?',
default=True, blank=True)
sale = models.IntegerField(verbose_name=u'Скидка',
blank=True, null=True)
is_active = models.BooleanField(verbose_name=u'Блюдо активно?',
default=True, blank=True)
shop = models.ForeignKey(Shop, verbose_name=u'Заведение',
related_name="dishshop")
是的,是的。 Dish claass需要通过限制为每个子菜单获取它