On 3/04/2015 12:01 AM, temiloluwa adesina wrote:
Hello
I just joined this group and i have problems with representing multiple
fields in admin using __unicode__, when i try to call this data it
returns just one of them:
|
classCrop(models.Model):
name =models.CharField(max_length=30)
importance =models.TextField()
cultivation =models.TextField()
def__unicode__(self):
returnu'%s %s %s'%(self.name,self.importance,self.cultivation)
|
<https://lh3.googleusercontent.com/-2cHWwMHqUnY/VR09L1-ntvI/AAAAAAAAAGY/AdVaYuoL6As/s1600/Screenshot%2B%2840%29.png>
but rather than returning just the data in the importance field, it
returns all the data in each separate field together.
That __unicode__() return value is a concatenation of the three named
fields and I assume that is what you want. When the object is returned
its name is mentioned first (Yam) followed by a space followed by
whatever data is in the importance field followed by a space then
cultivation
Your screenshot seems to be showing that.
If all you want is the importance info, just make __unicode__() return
that and nothing else.
Whatever is returned by __unicode__ is the object's identification.
You seem to have a good handle on that so I suspect I haven't understood
your question.
Mike
Pls i would appreciate anyone's assistance.
--
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
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto: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/504bf928-7259-4d17-994c-115e98a78a4b%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/504bf928-7259-4d17-994c-115e98a78a4b%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/551E1CD3.7000906%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.