2👍
You are not importing correctly. Change
url(r'^$', homepage.views.index, name='index'),
to
url(r'^$', index, name='index'),
0👍
Django is a web framework that is written in python, there is no magic involved.You are specifying full path to your view in urls.py
# here the view is available as index
from homepage.views import index
# so reference the view as index
url(r'^$', index, name='index'),
if you need to reference will full namespace,
# here the view can be imported as you intented
import homepage
url(r'^$', homepage.views.index, name='index'),
Things to be noted
ModuleNotFound
is raised when the module refered is not available,
in this case python
will try to use homepage
module but it is not available in the current context.
ImportError
is raised when the refered attribute or module is not available in already imported module or when you are using from module import x
.
>>> from os import wow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'wow'
- [Answered ]-What does an '_' in django url do?
- [Answered ]-How to get Uwsgi working with wagtail (django)
Source:stackexchange.com