5👍
✅
You should implement __str__
(or __unicode__
if Python 2) in the object’s model.
From Django’s docs:
Django uses str(obj) in a number of places. Most notably, to display an object in the Django admin site and as the value inserted into a template when it displays an object. Thus, you should always return a nice, human-readable representation of the model from the str() method.
0👍
Update your models.py like this:
class Campaign(models.Model):
user = models.ForeignKey(User)
campaign_name = models.CharField(max_length=50)
autoresponder_type = (
('Send replies to inbox messages','Send replies to inbox
messages'),
('Post replies to users comments','Post replies to users comments'),
)
facebook_account_to_use = models.ForeignKey(FacebookAccount)
set_auto_reply_for_fan_page = models.ForeignKey(FacebookFanPage)
message_list_to_use = models.ForeignKey(PredefinedMessage)
reply_only_for_this_keyword = models.CharField(max_length=50)
def __unicode__(self):
return self.campaign_name # or you can use any string value instead of campaign_name
- [Django]-Django select_related: How to display related table data in a template
- [Django]-Django query annotate values get list from reverse foreign key
- [Django]-How to fix Django error: " 'unicode' object has no attribute 'tzinfo' " on database read
- [Django]-Django won't connect to Redis Docker container
Source:stackexchange.com