Skip to content

Commit

Permalink
Merge pull request #31 from ramiro/bugfix/better-user-model-str
Browse files Browse the repository at this point in the history
avoid breakage when Use optional fields arent set.
  • Loading branch information
jlmadurga committed Jun 23, 2017
2 parents 5141ed0 + facd358 commit 4d1c794
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion telegrambot/models/telegram_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ class Meta:
verbose_name_plural = _('Users')

def __str__(self):
return "%s" % self.first_name
if self.first_name:
return "%s" % self.first_name
elif self.username:
return "%s" % self.username
else:
return "%d" % self.id

@python_2_unicode_compatible
class Chat(models.Model):
Expand Down

0 comments on commit 4d1c794

Please sign in to comment.