Django语法错误的形式polls.models导入

时间:2013-08-27 20:26:59

标签: python django

我正在使用窗口7我有Django 1.5和python 2.7并试图在它自己的网站上运行Django示例使用给定的语法但是当我运行命令时:>>> from polls.models import Poll, Choice我得到语法:

Erro: G:\p\mysite>python manage.py shell Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information.(InteractiveConsole)
>>> help Type help() for interactive help, or help(object) for help about object.
>>> form polls.models import Poll   File "<console>", line 1
    form polls.models import Poll
             ^ SyntaxError: invalid syntax

我的模特:

from django.db import models
class Poll(models.Model):
    question = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')

class Choice(models.Model):
    poll = models.ForeignKey(Poll)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)

我是python的新手,感谢任何帮助。

1 个答案:

答案 0 :(得分:3)

这只是一个错字:使用from代替form