I'm using python 2.4 and django 1.2.4 with MySQL 5.0 FWIW I have the following models (code deleted to simplify)
class Message(models.Model): facility = models.CharField(max_length=2, null=True, blank=True) msgtype = models.CharField(max_length=3) class Pv(models.Model): message = models.OneToOneField(Message, primary_key=True, db_column='id') location = models.CharField(max_length=6, null=True, blank=True) priorfacility = models.CharField(max_length=2, null=True, blank=True) Now I've discovered that on rare occasions Pv does not exists and thus referencing it like this for message in models.Message.objects.select_related(): new = [message.pv.facility, ... throws django.db.models.base.DoesNotExist: Pv matching query does not exist. When I encounter a missing PV record. Is this my improper use of OneToOneField and I should have used ForeignKeyField ? Is there a way to see if the PV object exists other than surrounding it with a try/except clause ? The times when Pv is missing are rare; would it make more sense to just create a record with nulls and maintain the 1-to-1 relationship? -- 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.