lsbardel/python-stdnet — Issue #21: Can not delete a model with a ManyToManyField
Author: kuno
Created: 2011-11-14 09:49:37+00:00
State: open

In [35]: a.delete()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/home/kuno/utopia/sogoke-django/sogoke/ in ()
----> 1 a.delete()

/home/kuno/utopia/sogoke-django/lib/python2.7/site-packages/stdnet/orm/models.pyc in delete(self, transaction)
165 for obj in self.related_objects():
166 T += obj.delete(transaction)
--> 167 res = T + meta.cursor.delete_object(self, transaction)
168 post_delete.send(sender=self.__class__, instance = self)
169 return res

/home/kuno/utopia/sogoke-django/lib/python2.7/site-packages/stdnet/backends/base.pyc in delete_object(self, obj, transaction)
167
168 self._remove_indexes(obj, transaction)
--> 169 self._delete_object(obj, transaction)
170
171 if commit:

/home/kuno/utopia/sogoke-django/lib/python2.7/site-packages/stdnet/backends/redisb.pyc in _delete_object(self, obj, transaction)
413 if mfs:
414 pipe = transaction.pipe
--> 415 fids = [fid for fid in (field.id(obj) for field in mfs) if fid]
416 if fids:
417 pipe.delete(*fids)

/home/kuno/utopia/sogoke-django/lib/python2.7/site-packages/stdnet/backends/redisb.pyc in ((field,))
413 if mfs:
414 pipe = transaction.pipe
--> 415 fids = [fid for fid in (field.id(obj) for field in mfs) if fid]
416 if fids:
417 pipe.delete(*fids)

/home/kuno/utopia/sogoke-django/lib/python2.7/site-packages/stdnet/orm/std.pyc in id(self, obj)
138
139 def id(self, obj):
--> 140 return getattr(obj,self.attname).id
141
142

AttributeError: 'M2MRelatedManager' object has no attribute 'id'