views:

33

answers:

1

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 getting:
maximum recursion depth exceeded while calling a Python object and 997 QUUID obects in db. Why is that happening ?

+6  A: 

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)
damn I totally forgot about that. Thanks !
owca