Maximum recursion depth exceeded when providing unique id
I wanted to provide unique ID for different categories of models in my db. So I've introduced a dummy model :
class GUUID(models.Model):
guuid = models.PositiveSmallIntegerField(_(u"Dummy GUUID"), default=1)
and in model that I want to have unique ID:
class Event(models.Model):
unique = models.IntegerField(blank=False, editable=False)
def save(self):
guuid = GUUID()
guuid.save()
self.unique = guuid.id
self.save()
But when saving my model I'm g开发者_运维问答etting:
maximum recursion depth exceeded while calling a Python object
and 997 QUUID obects in db. Why is that happening ?I think you want to replace self.save()
with super(Event, self).save()
. Also might not be a bad idea to grab the parameters from the Event save method and pass them up:
def save(self, *args, **kwargs):
#... other code here
super(Event, self).save(*args, **kwargs)
精彩评论