cant import views

590 views
Skip to first unread message

דביר חומרי

unread,
Mar 17, 2020, 2:03:10 PM3/17/20
to Django users
i was following the toturial and i could'nt find why this error is accure.
polls/urls.py'

from django.urls import path

from . import views

urlpatterns = [
   
path('', views.index, name='index'),
]

and got this error:

Traceback (most recent call last):
  File "c:\Users\......polls\urls.py", line 20, in <module>
    from . import views
ImportError: cannot import name 'views'

p.s. views.py is in the same directory as urls.py

victor awakan

unread,
Mar 17, 2020, 3:04:06 PM3/17/20
to django...@googlegroups.com
Try from polls import views and see if that solves the problem. Cheers 

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9c1f34af-2f3f-4a29-964f-056dd5f74ac2%40googlegroups.com.

surendra bhaskar

unread,
Mar 17, 2020, 3:46:31 PM3/17/20
to django...@googlegroups.com
There is some error in function 

PRAKASH SINGH

unread,
Mar 17, 2020, 4:49:39 PM3/17/20
to django...@googlegroups.com
Import error can be due to location of file or sometimes we forget to save the file after creating it so make sure taht the file is at right location and is saved.

Ganesh Babu

unread,
Mar 17, 2020, 10:54:16 PM3/17/20
to django...@googlegroups.com
Hi ,

 your file is not saved into correct place

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9c1f34af-2f3f-4a29-964f-056dd5f74ac2%40googlegroups.com.


--
Best Regards
Sri Ganesh Babu.S
Lead Software Engineer,
C2S technologies,
Ph: 9246425074


Jatin Agrawal

unread,
Mar 18, 2020, 1:53:02 AM3/18/20
to Django users
can you please share your project directory structure.

Integr@te System

unread,
Mar 18, 2020, 2:35:01 AM3/18/20
to django...@googlegroups.com
Dear Freind,

Plz check where your root project?
Or review base on code base vs. info you ps. at the end.

--
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.

דביר חומרי

unread,
Mar 18, 2020, 7:57:04 AM3/18/20
to Django users


בתאריך יום שלישי, 17 במרץ 2020 בשעה 20:03:10 UTC+2, מאת דביר חומרי:
the directory:
    __init__.py
    admin.py
    apps.py
    migrations/
        __init__.py
    models.py
    tests.py
    urls.py 
views.py 

Laurent Gattegno

unread,
Mar 18, 2020, 1:01:00 PM3/18/20
to django...@googlegroups.com
I think the problem is inside the views.py file. It looks like python doesnt find views.index and the problem may be the index
Laurent Gattegno


‪Le mer. 18 mars 2020 à 12:58, ‫דביר חומרי‬‎ <dvi...@gmail.com> a écrit :‬
--
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.

Sai Sandeep Rayanuthala

unread,
Mar 19, 2020, 1:24:09 AM3/19/20
to django...@googlegroups.com
There is no function index in views. That is the problem. Create a function named index in views. 

Reply all
Reply to author
Forward
0 new messages