Well, your class User doesn't have an attribute name you are using on the method __unicode__, you should define and set the attribute name with something like a textfield On Apr 13, 2015 3:21 AM, "makayabou" <makaya...@gmail.com> wrote:
> Hello, > > Sorry for the previous send unattended... > > I have problems trying to print values of a QUerySet Object in Admin View. > > In admin view, I would like to get a clear list of results, >> as defined in __unicode__ from class User. >> Instead, I get: >> >> <bound method User.__unicode__ of <User: Jean Dubois>> >> >> I just need Jean Dubois.. >> >> Here's the code: >> >> #In models.py: >> >> >> class PC(models.Model): >> def users(self): >> pc = self.user_set.all() >> for o in pc: >> return o.__unicode__ >> def __unicode__(self): >> return 'pc '+unicode(self.id)+' - '+self.os() >> >> >> >> >> class User(models.Model): >> mypc = models.ForeignKey(PC) >> def __unicode__(self): >> return self.name >> >> >> #In admin.py: >> >> >> class PcAdmin(admin.ModelAdmin): >> list_display = ('users','id') >> >> > Thanks for your help. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/61ec8171-77c5-4bba-9274-8f209422d15e%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/61ec8171-77c5-4bba-9274-8f209422d15e%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFWa6tLo5McP%3D2TS92a%2BkiUYpJKFTG9Agh1WzySuAaGdHAFrgQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.