Trouble With Tutorial #1 - NameError: name 'polls' is not defined

1,322 views
Skip to first unread message

michael....@farecompare.com

unread,
Oct 17, 2013, 4:05:17 PM10/17/13
to django...@googlegroups.com
Hi, 

I'm trying to learn Django and Python at the same time. So I realize this is a really simple issue for a beginner. But since I'm new to this, I could use a little help. 

Basically, I'm going through the tutorial here: 


I have gone through it up to the point where we create the polls app with the command: 

python manage.py startapp polls

I then created the models in polls/models.py by cutting and pasting from the article. 

Finally, to activate the new model, I went back to my settings.py file and added "polls" to my list of installed apps. However, when I run the command: 

python manage.py sql polls

I get the following error: 

Michael$ python manage.py sql polls
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/core/management/__init__.py", line 453, in execute_from_command_line
    utility.execute()
  File "/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/core/management/__init__.py", line 263, in fetch_command
    app_name = get_commands()[subcommand]
  File "/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/core/management/__init__.py", line 109, in get_commands
    apps = settings.INSTALLED_APPS
  File "/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/conf/__init__.py", line 53, in __getattr__
    self._setup(name)
  File "/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/conf/__init__.py", line 48, in _setup
    self._wrapped = Settings(settings_module)
  File "/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/conf/__init__.py", line 132, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Users/Michael/dev/projects/python/ape_admin/ape_admin/settings.py", line 127, in <module>
    polls,
NameError: name 'polls' is not defined

I have a folder called "polls" that is in the same directory as my manage.py file. Can someone tell me what I'm doing wrong? Is there a step I'm missing that's not in the tutorial that a Python developer would just know automatically? 

Thanks,

Michael

Daniel Roseman

unread,
Oct 17, 2013, 4:31:46 PM10/17/13
to django...@googlegroups.com
Sounds like you've put a line with just
   polls
in your INSTALLED_APPS, instead of
   "polls"
--
DR. 

michael....@farecompare.com

unread,
Oct 17, 2013, 4:34:28 PM10/17/13
to django...@googlegroups.com
Oh my gosh ... I did. LOL. Thanks. I'm an idiot.

Sarthak Khandelwal

unread,
Dec 16, 2018, 2:18:41 PM12/16/18
to Django users
can you send your file structure after this step?
I am having a similar problem, after adding views to url according to the tutorial in the documentation, when I was trying to run the server i was having a similar to your problem.
If anyone has completed this step please share the file structure to confirm if I am doing something wrong.

and yes I am not doing this error.

Daniel Hepper

unread,
Dec 17, 2018, 6:07:27 AM12/17/18
to django...@googlegroups.com

It's not updated for Django 2.1 yet, but the differences should not matter in your case.

Hope that helps,
Daniel

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e2a3e21b-6f32-4f67-8689-4f9a380f0b7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

BALA KRISHNAN

unread,
Dec 17, 2018, 2:36:06 PM12/17/18
to django...@googlegroups.com
you can change this url from your app 

from django.conf.urls import include, url
from django.contrib import admin
from django.views.generic import TemplateView
from rest_framework import routers

from user_profile.views import UserViewSet

router = routers.DefaultRouter()
router.register(r'user', UserViewSet,)

urlpatterns = [
url(r'^admin/', include(admin.site.urls)),

# This is used for user reset password
url(r'^', include('django.contrib.auth.urls')),
url(r'^rest-auth/', include('rest_auth.urls')),
url(r'^rest-auth/registration/', include('rest_auth.registration.urls')),
url(r'^account/', include('allauth.urls')),
url(r'^api/', include(router.urls)),
]

Aakash Choudhary

unread,
Dec 17, 2018, 3:33:58 PM12/17/18
to django...@googlegroups.com
Share the code I'll debug the error

--
Reply all
Reply to author
Forward
0 new messages