You should move the `polls/` subdirectory to the outer `mysite/` directory, rather than the inner `mysite/mysite/` directory. The tutorial does actually say this, but admittedly it's easy to miss:
Your apps can live anywhere on your Python path > <https://docs.python.org/3/tutorial/modules.html#tut-searchpath>. In this > tutorial, we’ll create our poll app right next to your manage.py file so > that it can be imported as its own top-level module, rather than a > submodule of mysite. You don't need to `import polls` in your urls.py, since it doesn't actually use the `polls` module, it only has a string reference to that module. Django takes care of importing whatever you pass to `include()` if it's a string reference. On Tuesday, June 6, 2017 at 3:51:18 AM UTC+2, kit...@gmail.com wrote: > > I was attempting the tutorial titled "Writing your first Django app". The > tutorial appears to be very simple, but it does not seem to work. I have > frustrated myself by attempting to do it from scratch after failing last > week. If I could get this app to work I could fix the tutorial for you. > It looks like a lot of people have similar gripes about the directions not > working. > > I get errors like ModuleNotFoundError: No module named 'polls' > > my directory structure looks like this : > > /home/me/parent/mysite/ > db.sqlite3 > manage.py > mysite/ > > /home/me/parent/mysite/mysite/ > __init__.py > polls/ > settings.py > urls.py > wsgi.py > > the content of urls.py is : > > from django.conf.urls import include, url > > from django.contrib import admin > > > urlpatterns = [ > > url(r'^polls/', include('polls.urls')), > > url(r'^admin/', admin.site.urls), > > ] > > > /home/me/parent/mysite/mysite/polls/ > __init__.py > admin.py > apps.py > migrations > models.py > tests.py > urls.py > views.py > > the content of urls.py is : > > from django.conf.urls import url > > > from . import views > > > urlpatterns = [ > > url(r'^$', views.index, name='index'), > > ] > > > > > the content of views.py is : > > > from django.shortcuts import render > > from django.http import HttpResponse > > > > # Create your views here. > > > def index(request): > > return HttpResponse("Hello, Mothers Fuckers! You're at the polls > index!") > > > > So can somebody please tell me why I get ModuleNotFoundError: No module > named 'polls'. > > > > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@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/4a9e3c66-2369-4493-a2e7-0efbc3ba54dd%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.