I have a model that allows my client to create menus for his restaurant. Everything works great except I would like to set the explicit ordering by the string value of a model. For instance; he is creating sections like Salads, Pastas, Pizzas etc.. but they are displayed through the template in the order they are added to the system. How can I add a sort to my query that I can set the order manually? Below is my current snippet.
I am using Django 1.10.5, Wagtail 1.9, Python 3.5x
Snippet
@register.inclusion_tag('tags/_lunch-menu-list.html', takes_context=True)
def lunch_products(context):
sections = Section.objects.all().prefetch_related('product').filter(product__lunch_menu=True).distinct()
return {
'sections': sections,
'request': context['request'],
}