- 重要な情報
- はじめに
- 用語集
- ガイド
- エージェント
- インテグレーション
- OpenTelemetry
- 開発者
- API
- CoScreen
- アプリ内
- Service Management
- インフラストラクチャー
- アプリケーションパフォーマンス
- 継続的インテグレーション
- ログ管理
- セキュリティ
- UX モニタリング
- 管理
ID: python-django/no-unicode-on-models
言語: Python
重大度: 警告
カテゴリー: ベストプラクティス
Django モデルでは __unicode__
を使用しないでください。フィールド __unicode__
は Python 2 で使用されます。代わりに __str__
を使用し、__str__
は Python 3 で使用します。
class Person(models.Model):
def __unicode__(self): # __unicode__ を定義せず、__str__ を定義します
pass
class Person(models.Model):
def __str__(self):
"person"