Yes foreignkey is an object but there must be a way to display the
value in a list_display. I am a newbie too. self.maphdid.id doesnt
work

On 26 Mart, 06:05, Thierry Chich <thierry.ch...@gmail.com> wrote:
> Le vendredi 26 mars 2010 04:14:51, Asim Yuksel a écrit :
>
> > I have a question about model.ForeignKey field.Foreign key fields are
> > shown as object in admin page. How can I show them in other types like
> > integer type
> > for example I have a Model like this:
>
> > class Advisor(models.Model):
>
> >     advisorid = models.IntegerField(primary_key=True,
> > db_column='advisorId')
> >     maphdid = models.ForeignKey(Tblmaphds, db_column='maPhDId')
> >     def __str__(self):
> >         return smart_str('%s' % (self.maphdid))
> >     def __unicode__(self):
> >         return smart_str('%s' % (self.maphdid))
> >     class Meta:
> >         db_table = 'Advisor'
>
> > The problem is I see the maphdid value as "Tblmaphds object" instead
> > of a normal integer value.
>
> > What should I do to see a integer value?
>
> I am not sure of what I say because I just begin with django, but it seems to
> me that you are confusing foreignkey in models and foreignkey in SQL database.
> For me, a foreignkey in django is an object, not an id.
>
> So, it seems to me that maphdid is an object Tblmaphds. If you want to print
> the Tblmaphds.id value, you shoud have
> to write
>          return smart_str('%s' % (self.maphdid.id))

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