在Django默认的后台管理系统中,在注册了新的内容之后,会发现记录的显示为源码中的类名,显得非常的不美观,也不容易区分。

Django models.py 中__unicode__和__str__的区别

Django models.py 中__unicode__和__str__的区别 

Django models.py 中__unicode__和__str__的区别

针对上述问题可以在model中增加__unicode__(python2) 或 __str__(python3) 的方法

Django models.py 中__unicode__和__str__的区别

 

Django models.py 中__unicode__和__str__的区别

相关文章:

  • 2021-07-21
  • 2021-05-22
  • 2021-07-27
  • 2022-01-15
  • 2021-07-06
  • 2021-06-06
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-02
  • 2021-08-21
  • 2022-12-23
  • 2021-09-22
相关资源
相似解决方案