Given the model's below, I'm trying to make it add the related 1-1
record automatically, but it's not working, what am i missing?

Thanks

John



class unixhost(models.Model):
        name = models.CharField(max_length=50)                          # short 
name
        fqdn = models.CharField(max_length=50)                          # FQDN
        os = models.CharField(max_length=10, blank=True)        # What OS is on 
the
box.
        level = models.CharField(max_length=10, blank=True)             # Prod, 
QA, DR,
DEV

        # default manager
        objects = models.Manager()

        def save(self, force_insert=False, force_update=False):
                # check if 1-1 record is needed
                if self.id == None:
                        # Create a hostsetting object
                        print "adding hostsetting to new object"
                        hs = hostsetting()
                        self.hostsetting = hs

                super(unixhost, self).save(force_insert, force_update) # call 
the
real one.

        def __unicode__(self):
                return self.name

class hostsetting(models.Model):
        host = models.OneToOneField(unixhost)
        hostinfo = models.BooleanField(blank=True)      # have we gotten the
hostinfo on this box yet?
        users = models.BooleanField(blank=True)         # have we collected 
users on
this box?
        installed = models.BooleanField(blank=True)     # is likewise installed?
        delay = models.BooleanField(blank=True)         # is this delayed?

        # default manager
        objects = models.Manager()

        def __unicode__(self):
                return "Settings for host " + self.host.name
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to