Note that there are some explanatory texts on larger screens.

plurals
  1. POImportError: cannot import name Poll
    primarykey
    data
    text
    <p>I have followed all the steps in this <a href="https://docs.djangoproject.com/en/1.6/intro/tutorial01/" rel="nofollow">tutorial</a> but I received this error. How can it be fixed?</p> <pre><code>dyn-72-33-214-65:mysite mona$ python manage.py shell Python 2.7.5 (default, Sep 2 2013, 05:24:04) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) &gt;&gt;&gt; from polls.models import Poll, Choice Traceback (most recent call last): File "&lt;console&gt;", line 1, in &lt;module&gt; ImportError: cannot import name Poll </code></pre> <p>Directory structure is as follows:</p> <pre><code>&gt;&gt;&gt; quit() dyn-72-33-214-65:mysite mona$ pwd /Users/mona/data_mining/mysite dyn-72-33-214-65:mysite mona$ ls db.sqlite3 manage.py mysite polls dyn-72-33-214-65:mysite mona$ cd polls/ dyn-72-33-214-65:polls mona$ ls __init__.py admin.py models.pyc views.py __init__.pyc models.py tests.py dyn-72-33-214-65:polls mona$ cd ../mysite/ dyn-72-33-214-65:mysite mona$ ls __init__.py settings.py urls.py __init__.pyc settings.pyc wsgi.py </code></pre> <p>Answer: Missed to add these lines in models.py from django.db import models</p> <pre><code>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) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload