I have a Thread and a Message model, as defined below:

class Thread(models.Model):
        modified = models.DateTimeField(auto_now=True, auto_now_add=True)

class Message(models.Model):
        subject = models.CharField(max_length = 100)
        thread = models.ForeignKey(Thread, related_name='thread',
null=True)
        content = models.TextField()
        sent = models.DateTimeField('timestamp', auto_now_add=True)
        read = models.BooleanField(default = 0)
        sender = models.ForeignKey(User, related_name='sender')
        thread = models.ForeignKey(Thread, related_name='thread', null=True)
        recipient = models.ForeignKey(User, related_name='recipient')

        def save(self, *args, **kwargs):
                if self.thread is None:
                        self.thread = Thread()
                self.thread.save()
                super(Message, self).save(*args, **kwargs)

I'd expect to be able all the messages for a given thread with
thread.message_set, but I get the following AttributeError when i try
that: 'Thread' object has no attribute 'message_set'. Any suggestions
on why?

Thanks, Ben

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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