0

I'm trying to use this line in urls.py:

from mysite.urls.views import Index

However, Django is saying

ImportError at / 
No module named views

I think that is because it's going into /mysite/mysite/urls.py and not /mysite/urls/views.py

The structure is like this (omitted the uninvolved files):

mysite/
    templates/
    mysite/
        settings.py
        urls.py
    urls/
        views.py
    manage.py
User
  • 23,729
  • 38
  • 124
  • 207

3 Answers3

1

I found out that was my problem. I followed How to change the name of a Django app? and my problems went away. Long story short, don't name your app: urls.

Community
  • 1
  • 1
User
  • 23,729
  • 38
  • 124
  • 207
0

Absolute imports may be what you need:

from __future__ import absolute_import

Credits to this answer: https://stackoverflow.com/a/4931577/1028012

romifz
  • 135
  • 10
0

Add an empty __init__.py inside your urls folder. Why that should work? Take a look here and here

Community
  • 1
  • 1
trinchet
  • 6,753
  • 4
  • 37
  • 60