import logging
from django.db import models
-from django.db.models.signals import pre_save
+from django.db.models.signals import pre_save, post_init
from samples.models import Library
from experiments.models import FlowCell
try:
import uuid
-except ImportError, e:
+except ImportError as e:
# Some systems are using python 2.4, which doesn't have uuid
# this is a stub
LOGGER.warning('Real uuid is not available, initializing fake uuid module')
"""
Assigns a UUID to model on save
"""
- #print 'Entered _assign_uuid'
if instance.uuid is None or len(instance.uuid) != 32:
instance.uuid = uuid.uuid1().hex
else:
return u"%s: %s" % (self.name, self.location_description)
-pre_save.connect(_assign_uuid, sender=Location)
+post_init.connect(_assign_uuid, sender=Location)
class ItemInfo(models.Model):
def get_absolute_url(self):
return '/inventory/%s/' % (self.uuid)
-pre_save.connect(_assign_uuid, sender=Item)
+post_init.connect(_assign_uuid, sender=Item)
class PrinterTemplate(models.Model):