Hi,
On Sun, May 17, 2009 at 10:59 PM, Thierry wrote:
>
> I currently have a blog model:
>
> [BlogPost Model]
>
> Right now, author is returning the default User.username. I have
> other models who has a ForeignKey to User, I want them to keep
> defaulting to username while for Blogpost, I want
Sorry, pressed that button too early:
You could also write a default method inside your BlogPost model.
Maybe something like:
class BlogPost(models.Model):
...
def author_name(self):
return '%s %s' % (self.author.first_name, self.author.last_name)
--~--~-~--~~
If you're using the most recent version of django you can use a Proxy
Model:
(I think this will work but I've never tried it)
class Author(User):
class Meta:
proxy = True
#Here you redefine the default behavior of
#of the __unicode__ function
def __unicode__(self):
3 matches
Mail list logo