Define Self as multiple attributes in Django
I'm new to Django and building my first app.
I want locations in my Admin section to be displayed by a combination of different attributes from the model.
Currently they are shown by the icon by using the following code.
def __unicode__(self):
return self.icon
I want to be able to add my other two attributes to this code so that th开发者_JS百科e result will look like.
"Icon(Attribute1, Attribute2)"
How can I edit the code to do this?
If I have understood you correctly then the following should produce the result that you are looking for (but you'll need to edit the attribute names):
def __unicode__(self):
return u"{0} ({1}, {2})".format(self.icon, self.attrib1, self.attrib2)
精彩评论