I have a Publicationand Authors. Since the issue of ordering Authormatters (the professor does not want to be included after the trainee who contributed some trivial data), I defined a many-to-many user model:
class Authorship(models.Model):
author = models.ForeignKey("Author")
publication = models.ForeignKey("Publication")
ordering = models.IntegerField(default=0)
class Author(models.Model):
name = models.CharField(max_length=100)
class Publication(models.Model):
title = models.CharField(max_length=100)
authors = models.ManyToManyField(Author, through=Authorship)
I have ModelFormto publish and use it in a view. The problem is that when invoked, form.save()authors are obviously added with the default order 0. I wrote a OrderedModelMultipleChoiceFieldwith a method cleanthat returns objects that will be stored in the correct order, but I did not find a hook where the m2m data is actually stored so that I can add / edit / delete instances Authorship.
Any ideas?