I have a model/table, WeekOne
with various fields. It also has a unicode field:
def __unicode__(self):
return u'Week One'
WeekOne
is a foreign key of user
, defined using the variable weekOne.
Thinking I could leverage the unicode field in a template, I tried to display the name using the following code:
{{ user.weekOne }}
Nothing showed up. It's not an issue of my models functioning properly, I access other fields in model/weekOne throughout the template without issue. What's the best way to display the name of a table? Do I need to create a "Name" field? That seems like kind of a waste, since every user would have a WeekOne table with the redundant "Name" field.
Here is the model of UserProfile, which is what the user variable references:
class UserProfile(models.Model):
user = models.OneToOneField(User)
weekOne = models.OneToOneField(WeekOne)
When I do something like user.weekOne.items (items is a field in weekOne), it shows up on the template.