Printing Objects in Django

前端 未结 3 1550
庸人自扰
庸人自扰 2020-12-31 04:30

So I\'ve connected Django to a pre-existing database successfully (inspect, validate and sync) and I\'ve created an app and a project and all that (I\'m reading the Django b

3条回答
  •  情歌与酒
    2020-12-31 05:02

    UPDATE: In Python 3.x, use __str__ instead of __unicode__

    What you are seeing is a list of Artist model instances. Your values are in a python object. If you would like to make the representation of those instances more helpful, you should define the __unicode__ method for them to print something useful:

    https://docs.djangoproject.com/en/dev/ref/models/instances/?from=olddocs#unicode

    Its not a placeholder, its the actual object's representation, converted to unicode.

提交回复
热议问题