I'm taking a django course and when I go to put urls, it's causing this problem:
Code:
Folder structure:
CodePudding user response:
This is because of absolute imports being in effect (more precisely, the lack of implicit relative imports) for Python 3 and the fact that the pyping
module was most likely only written for Python 2. Whereas in Python 2 you can do:
from core.views import home
In Python 3 (or if you have from __future__ import absolute_import
in Python 2), you have to do:
from .core.views import home
or
from pyping.core.views import home
You can try this.
CodePudding user response:
So to import the views from core you should do
from core import views as core_views
then in your main projects urls.py you can use this by
path('',core_views.home,name='home)
You should also make sure that your app core, is in the INSTALLED APPS in your main projects Settings.py
Also make sure that in your core.views that a view exists for home
Lmk if this works