django の manytomany フィールドで TypeError: 'User' object has no attribute '__getitem__'

django manytomany フィールドで以下の様なエラーがでたので対策した。

TypeError: 'User' object has no attribute '__getitem__'

のエラーが出た。
モデルは次のようなもの。

  class Staff(models.Model):
      name = models.ForeignKey(User, related_name='staffname')
      group = models.ForeignKey(Groups, related_name='staffname')

      def __unicode__(self):
          return self.name

python - TypeError 'x' object has no attribute '__getitem__' - Stack Overflow
とか見たら unicodeのところがおかしいでしょってことで
次のように返り値を修正して解決。

      def __unicode__(self):
          return unicode(self.name)