Re: Cant Import mysite.urls
On Monday, September 10, 2012 8:29:12 PM UTC-3, Jon Blake wrote:
Working through getting Django to work with Apache, mod_wsgi and Oracle database back end. When I enter my site URL, I get a "ImportError at /" page, with an exception value of "No module named mysite.urls".
Part 3 of the tutorial refers to line ROOT_URLCONF = 'mysite.urls', which I have in my settings.py module. I don't have a file mysite.urls. The tutorial then goes on to discuss editing utls.py, (which I do have) and states that Django will load this module (utils.py) because ROOT_URLCONF points to it. I don't understand that bit - what's the connection between mysite.urls and utils.py, and how does Django import mysite.urls if it does not exist?
It can be a bit confusing the first time you run into it, but "mysite.urls" isn't a file. It's a namespaced import path. So in this case, it is looking for an urls.py file in the mysite directory.
In the tutorial it's assumed that you named your project mysite. If you called it something else (say tutorial), the import path would be "tutorial.urls".
If you are using Django 1.4 and followed the tutorial by using the django-admin.py startproject command (which builds a project skeleton for you), the urls.py file should be in the same directory as your settings.py file.
I couldn't find a reference to utils.py in the tutorial so I assume it must be an accidental typo and probably the cause of the error you're seeing.
-- You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/rFQ5vJp_0mcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home