path(' ', views.index, name= 'index'), AttributeError: module 'learning_logs.views' has no attribute 'index'

Viewed 995
from django.urls import path
from . import views

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

Issue is related to views or index please help. path(' ', views.index, name= 'index'), AttributeError: module 'learning_logs.views' has no attribute 'index'

3 Answers

enter code here`In the books python crash course in the later page this error has been resolved by defining a function index. I also had the issue so I read further and it had said to define the index function in views.py.

def index(request):
    return render(request, 'learning_logs/index.html')

Please try this: Here app_name is the name of the current application you written index function.

from django.urls import path
from learning_logs.views import index

urlpatterns = [
    #Home page,
    path('',index, name='index'),
]

Just add an index function in your learning_logs.views.py as:

def index(request):
    pass
Related