Re: How to use primary key as an attribute

2013-12-01 Thread Aamu Padi
You are really are a life saver. Thank you so much sir. I have posted a more specific question. Please kindly have a look at it. Thank you. On Sun, Dec 1, 2013 at 5:09 PM, Timothy W. Cook wrote: > If I understand what you are building. You want some way to group > messages into threads? I assu

Re: How to use primary key as an attribute

2013-12-01 Thread Timothy W. Cook
If I understand what you are building. You want some way to group messages into threads? I assume that a Thread will have many messages? Unless I am missing something you might want something like this: class Thread(models.Model): subject = models.CharField(max_length=256) class Message(mod

Re: How to use primary key as an attribute

2013-12-01 Thread Aamu Padi
Actually I need to use *Thread* class in other class as a ForeignKey. Here is the whole code: class Thread(models.Model): thread_pk = models.PositiveIntegerField(default=self.pk) class ThreadParticipant(models.Model): thread = models.ForeignKey(Thread) user = models.ForeignKey(User)

Re: How to use primary key as an attribute

2013-11-30 Thread Timothy W. Cook
I'm not sure what you are trying to accomplish. Since the 'pk' field is going to be defined on your instances anyway, do you need a 'thread_pk' field? On Sat, Nov 30, 2013 at 3:38 PM, Aamu Padi wrote: > This may be a lame question, but how do I use the primary key as a default > value for an attr