Shunted responsibility for 404 and 500 error catching from node_view to RequestNodeMi...
[philo.git] / models / base.py
index 1b6e60f..fdfe75c 100644 (file)
@@ -128,10 +128,15 @@ class ManyToManyValue(AttributeValue):
                # Value is probably a queryset - but allow any iterable.
                
                # These lines shouldn't be necessary; however, if value is an EmptyQuerySet,
-               # the code won't work without them. Unclear why...
+               # the code (specifically the object_id__in query) won't work without them. Unclear why...
                if not value:
                        value = []
                
+               # Before we can fiddle with the many-to-many to foreignkeyvalues, we need
+               # a pk.
+               if self.pk is None:
+                       self.save()
+               
                if isinstance(value, models.query.QuerySet):
                        value = value.values_list('id', flat=True)