On Mon, May 9, 2011 at 3:32 AM, chhots <bayasa...@gmail.com> wrote:

> class Like(models.Model):
> smartbuy = models.ForeignKey(SmartBuy)
> User = models.ForeignKey(User)
> def __unicode__(self):
> return self.smartbuy or “Smartbuy #%d” % self.smartbuy
>

What are you trying to do here? If you are trying to do something different
depending on if self.smartbuy has a value you have not accomplished it with
that statement. Well, maybe you have but the fact that you are still trying
to use self.smartbuy's value in the case where it doesn't have a (non-empty)
value indicates the code is probably not really doing what you were
intending.

Returning self.smartbuy is your problem: your __unicode__ method needs to
return unicode, not an instance of some other Django model, which is what
return self.smartbuy does.

Karen
-- 
http://tracey.org/kmt/

-- 
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