django-tables - Related field verbose name -


i'm using django-tables , trying display table containing related fields.

class user(models.model):     name = models.charfield(_("name"), max_length=100)     comp = models.foreignkey(company)  class company(models.model):     name = models.charfield(_("name"), max_length=100)     country = models.charfield(_("country"), max_length=200)     def __unicode__(self):         return self.name  class usertable(tables.table):     class meta:         model = user         fields = ('name', 'comp', 'comp.country',)         empty_text = _('no user') 

i correct data comp in each related heading

+------+----------------+-----------------+ | name | comp           | comp            | +------+----------------+-----------------+ | bob  | comp 1         | france          | | john | comp 2         | united kingdom  | | ...  | ...            | ...             | +------+----------------+-----------------+ 

what reason ?
shouldn't name, comp, country ?


update

mistake on original question, have updated it.

from django-table docs -

fields – specify model fields include

but you're including relationships -

fields = ('user', 'user.pref.country', 'user.pref.phone',) 

i never used app, i'm not sure how it's working, think it's taking verbose name of each field, in later 2 cases, user field comes first, hence it's taking user fields' verbose name.

update:

it seems can provide custom verbose names, try this. not sure if work, country related field. -

class usertable(tables.table):     country = tables.column(verbose_name="country")      class meta:         model = user         fields = ('name', 'comp', 'comp.country',)         empty_text = _('no user') 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -