Re: AttributeError: module 'polls.views' has no attribute 'index' error in Django

2024-12-07 Thread Олександр Рябов
Guys, thanks for the help everyone but I just used vim and rewrote the code 
again)

On Thursday, 5 December 2024 at 15:02:36 UTC+3 Олександр Рябов wrote:

> Hello! I'm facing an issue when running my Django project. I get the 
> following error:
>
> AttributeError: module 'polls.views' has no attribute 'index'
>
> I've checked the following:  
> 1) In "polls/views.py", I have defined the index function:
> from django.http import HttpResponse
> 
> def index(request):
> return HttpResponse("Hello, World!")
>
> 2) In polls/urls.py, the path to this function is correctly defined:
> from django.urls import path, include
> from . import views
>
> urlpatterns = [
> path("", views.index, name="index"),
> ]
> 3) In the main mysite/urls.py, the URLs from polls are included:
> from django.contrib import admin
> from django.urls import include, path
>
> urlpatterns = [
> path("polls/", include("polls.urls")),
> path("admin/", admin.site.urls),
> ]
>
> However, when I run the server with the command:
> " python manage.py runserver "  
>
> I get the error mentioned above. I have also made sure that all imports 
> are correct and that the project is using the right Python version.
>
> What could be the cause of this error and how can I fix it? Thank you!
> P.S. 
> - I am writing my code in Visual Studio Code and have attached two 
> pictures for reference.
> - The first picture shows the general structure of my project.
> - The second picture displays the full error message from the command 
> line(*try to enlarge it, I hope you can see everything.)
> #1
>
> [image: photo_1.png]
> #2
> [image: photo_2.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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-users/f04cf8be-2103-4bb9-9ef3-7bf90ddbb1edn%40googlegroups.com.


Re: AttributeError: module 'polls.views' has no attribute 'index' error in Django

2024-12-06 Thread Abduljelil Zubairu
is your VS Code on auto save 

On Thursday, December 5, 2024 at 1:02:36 PM UTC+1 Олександр Рябов wrote:

> Hello! I'm facing an issue when running my Django project. I get the 
> following error:
>
> AttributeError: module 'polls.views' has no attribute 'index'
>
> I've checked the following:  
> 1) In "polls/views.py", I have defined the index function:
> from django.http import HttpResponse
> 
> def index(request):
> return HttpResponse("Hello, World!")
>
> 2) In polls/urls.py, the path to this function is correctly defined:
> from django.urls import path, include
> from . import views
>
> urlpatterns = [
> path("", views.index, name="index"),
> ]
> 3) In the main mysite/urls.py, the URLs from polls are included:
> from django.contrib import admin
> from django.urls import include, path
>
> urlpatterns = [
> path("polls/", include("polls.urls")),
> path("admin/", admin.site.urls),
> ]
>
> However, when I run the server with the command:
> " python manage.py runserver "  
>
> I get the error mentioned above. I have also made sure that all imports 
> are correct and that the project is using the right Python version.
>
> What could be the cause of this error and how can I fix it? Thank you!
> P.S. 
> - I am writing my code in Visual Studio Code and have attached two 
> pictures for reference.
> - The first picture shows the general structure of my project.
> - The second picture displays the full error message from the command 
> line(*try to enlarge it, I hope you can see everything.)
> #1
>
> [image: photo_1.png]
> #2
> [image: photo_2.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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-users/3ac25773-c449-444e-9d69-d20f23af18cdn%40googlegroups.com.