ValueError: attempted relative import beyond top-level package

428 views
Skip to first unread message

Bulgarian seller

unread,
Mar 2, 2019, 4:42:20 PM3/2/19
to Django users
from ..appTwo import views
urlpatterns
= [
    path
('',views.index),
    path
('admin/', admin.site.urls),
]

 
ValueError: attempted relative import beyond top-level package
How to fix it in django?
I have this in AppTwo.views  
def index(request):
   
return HttpResponse("<em>My Second Project</em>")

Capture.PNG


李骏

unread,
Mar 2, 2019, 10:05:29 PM3/2/19
to django...@googlegroups.com
Settings.py:
“../apptwo”  ==> “appTwo.apps.apptwoconfig”,

发自我的 空间传送门

<Capture.PNG>


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/66c7e5ce-fafc-45d7-aa75-3a0ffb499ed5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<Capture.PNG>

Phako Perez

unread,
Mar 2, 2019, 10:08:00 PM3/2/19
to django...@googlegroups.com
I guess you miss the __init__.py file in project1 directory


Sent from my iPhone

<Capture.PNG>


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/66c7e5ce-fafc-45d7-aa75-3a0ffb499ed5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<Capture.PNG>
Reply all
Reply to author
Forward
0 new messages