Reputation: 1345
I have a the beginnings of a recipe app. Users add methods to a recipe one at a time. In a recipe app it is important that the methods appear in the correct order. I want the users to be able to order and re-order the stages of the methods until they are satisfied everything looks good but I have no idea:
A. How to allow the users to reorder methods
B. The best way to store the ordered methods
class Recipe(models.Model):
title = models.CharField(max_length=80)
slug = models.SlugField(max_length=80)
description = models.TextField(max_length=1000)
history = models.TextField(max_length=1000)
image = models.ImageField(upload_to='recipes/recipes')
class Method(models.Model):
recipe = models.ForeignKey(Recipe)
method = models.CharField(max_length=80)
image = models.ImageField(upload_to='recipes/methods', blank=True)
Here are the unordered methods that need ordering for a haggis recipe
What strategies for allowing users to order this list are available to me?
Upvotes: 1
Views: 420
Reputation: 136
Use an ordered model: https://github.com/bfirsh/django-ordered-model Then you can just: Method.up()/Method.down()
Upvotes: 2