模型.py
from django.db import models
import datetime
from django.utils import timezone
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
def __unicode__(self):
return self.choice_text
每当我进入
Poll.objects.all()
其中 Poll 是它显示的表名
[<Poll: Poll object>,<Poll: Poll object>]
但我希望输出包含表格的内容。我应该怎么办?请帮助我,因为我是 python 新手。
我试过了:
class Poll(models.Model):
title = models.CharField(max_length=128)
def __unicode__(self):
return self.title
我尝试了上述步骤但是当我运行 python manage.py shell 它给出了 ERROR IndentationError: unexpected indent (models.py, line 8)