I have a System model in one app that I'd like to connect to a Queue model in another app (django-helpdesk). If no Queue object is selected for a System object, I'd like to initialize a new Queue object, using information from the System to generate it.
I've covered all of the required fields for the Queue, and yet this doesn't seem to work. It doesn't throw an error; it just never generates a new Queue object. Can anyone spot the issue in question, or recommend another way of covering this?
#models.py
import helpdesk
....
class System(models.Model):
queue = models.ForeignKey(
helpdesk.models.Queue,
blank = True,
null = True,
editable = True,
verbose_name = _('Queue'),
)
def __save__(self, *args, **kwargs):
if not self.queue:
slug = slugify(self.name)
queue = helpdesk.models.Queue(title=self.name, slug=slug)
queue.save()
self.queue = queue.pk
super(System, self).save(*args, **kwargs)
EDIT: For reference, there's an additional mistake beyond using the double underscores for the save()
method. The line self.queue = queue.pk
should instead be self.queue = queue
.