Russell Keith-Magee wrote: > #3297 - FileField/ImageField for newforms > http://code.djangoproject.com/ticket/3297
+1 > #4001 - saving m2m fields on newforms with commit=False > http://code.djangoproject.com/ticket/4001 -1 The save_m2m() seems a bit weird to me too. Sometimes it's there, sometimes it's not. Also, this sort of logic seems to me like it should be in the Model class instead. After all, it's not the form that has the problem with not saving m2m data, the Model instances can't do it themselves. What if we let the Model instance temporarily store any many-to-many fields' data until the instance gets saved. So with models like: class Author(models.Model): name = CharField() class Book(models.Model): title = CharField() authors = ManyToManyField(Author) you could do: authors = Author.objects.filter(name__contains="Gary") new_book = Book(title="Hello World", authors=authors) new_book.save() Where save() would first save the Book and then save the Book-Author relationships. To implement this, maybe ReverseManyRelatedObjectsDescriptor.__set__ could store the related objects somewhere in the passed Model instance instead of calling manager.clear() and manager.add(). Then, let the Model instance's save() method do the manager.clear() and manager.add() after saving itself first. This would, however, mean that code that sets the m2m objects: mybook.authors = [...] wouldn't hit the database until mybook.save(), a change from the current behavior. I guess this would also mean that we would have to rethink whether or not the other manager functions (add(), remove(), etc.) would also not hit the database until save(). But having this logic in the Model would free client code (the form code in this case) from having to know whether or not a model instance has many-to-many fields and whether or not it needs to call some other save_m2m() method after calling save(). Thoughts? > #4418 - Newforms media > http://code.djangoproject.com/ticket/4418 +1 Gary --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---
