0

我正在使用窗口 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的新手,感谢您的帮助。

4

1 回答 1

3

这只是一个错字:使用from而不是form.

于 2013-08-27T20:29:40.487 回答