模型.py
class ReportType(models.Model):
report = models.ForeignKey(Report)
title = models.CharField('Incident Type', max_length=200)
def __unicode__(self):
return self.title
视图.py
def where(request):
user=request.user
try:
report = Report.objects.get(user=user.id)
except:
report = None
reporttype = ReportType.objects.all()
. . .
. . .
return render(request, 'incident/where.html',
{
'newreport_menu': True,
'reporttype':reporttype
})
它以这种形式给我输出。[<ReportType: Bike parking>, <ReportType: car parking>]
如何显示像这样的值“自行车停车场,停车场”。