8👍
I can’t re-produce the import error on my machine using your project files (Windows 7, Django 1.1.1, Python 2.6.4). Everything imported fine but the urls were not specified properly (like the tutorial shows). Fixing the code:
/mysite/urls.py:
from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
(r'^polls/', include('mysite.polls.urls')),
(r'^admin/', include(admin.site.urls)),
)
/mysite/polls/urls.py:
from django.conf.urls.defaults import *
urlpatterns = patterns('mysite.polls.views',
(r'^$', 'index'),
(r'^(?P<poll_id>\d+)/$', 'detail'),
(r'^(?P<poll_id>\d+)/results/$', 'results'),
(r'^(?P<poll_id>\d+)/vote/$', 'vote'),
)
Visit http://127.0.0.1:8000/polls/ – I received a TemplateDoesNotExist exception because the template file is missing.
I’m afraid my answer might be to reboot and try it again. 😉
52👍
I had a similar problem in my project root … django complained that it couldn’t find the module mysite.urls.
Turns out my ROOT_URLCONF variable in settings.py, which was set up using the default values, was set incorrect. Instead of “mysite.urls”, it should have been simply “urls”
I changed it, and voila, it worked.
- [Django]-Django Python rest framework, No 'Access-Control-Allow-Origin' header is present on the requested resource in chrome, works in firefox
- [Django]-What is the function of the name parameter in django.urls.path?
- [Django]-How can I MODIFY django to create "view" permission?
- [Django]-Django storing anonymous user data
- [Django]-Django :How to integrate Django Rest framework in an existing application?
- [Django]-Multiple copies of a pytest fixture
5👍
I also had a weird problem with “No module named mysite.urls”.
The admin site was down and the my whole site.
The solution, after a few hours of searching the web, was on my side : Django is caching some of the settings in a file that he knows from an environment variable.
I just closed my terminal in which i was doing the runnserver thing and opened a new one.
- [Django]-Understanding ManyToMany fields in Django with a through model
- [Django]-Redirect to named url pattern directly from urls.py in django?
- [Django]-Why don't my south migrations work?
1👍
I did exactly the same thing. Python newbie mistake by reading ahead. I created a file call “polls.url” thinking it was some sort of special django template file.
I misunderstood the text:
“Now that we’ve decoupled that, we need to decouple the polls.urls URLconf by removing the leading “polls/” from each line, and removing the lines registering the admin site. Your polls.urls file should now look like this:
“
It should really read:
“Now that we’ve decoupled that, we need to decouple the polls.urls URLconf by removing the leading “polls/” from each line, and removing the lines registering the admin site. Your polls/urls.py file should now look like this:
“
- [Django]-Django-AttributeError 'User' object has no attribute 'backend' (But….it does?)
- [Django]-Django – run a function every x seconds
- [Django]-How do I perform query filtering in django templates
1👍
Late to the party but I fixed my problem by correcting a typo inside settings.py INSTALLED_APPS. I had ‘webbapp’ instead of ‘webapp’ so you might want to check on that as well (for people still having the problem)
- [Django]-Django: accessing the model instance from within ModelAdmin?
- [Django]-How do i debug/breakpoint my django app using pycharm?
- [Django]-How to deploy django under a suburl behind nginx
0👍
Like Ryan Bagwell, problem was (at least temporarily) solved by changing ROOT_URLCONF in myproject/myproject/settings.py.
I had to add “myproject” to ROOT_URLCONF to have there this:
“%s.myproject.urls” % PROJECT_APP
- [Django]-Django templates – split string to array
- [Django]-How to remove all relations from manytomany?
- [Django]-Where to put Django startup code?