简体   繁体   中英

My django project is not importing files from the same directory

from django.urls import path
from .entries import views
  
urlpatterns = [
    path('', views.index),
    path('add/', views.add)
]

This is my code..I am getting this error:

from .entries import views
ImportError: attempted relative import with no known parent 
package

you need to name the imported views. try with:

from entries import views as entries_views
from django.urls import path
from entries import views
  
urlpatterns = [
    path('', views.index),
    path('add', views.add)
]

write like this Your Mistack is: from **.**entries import views remove this.(dot)

I hope this information help you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM