I have a Django app where I have the following code:
[app]/urls.py
urlpatterns = [
path('', views.IndexView.as_view(), name='index'),
...
]
[app]/views.py
from django.http import HttpResponseRedirect
from .models import Chat
from .models import Message
from django.shortcuts import render
from django.shortcuts import get_object_or_404
from django.urls import reverse
from django.views import generic
from django.utils import timezone
from django.contrib.auth.decorators import login_required
@login_required()
class IndexView(generic.ListView):
template_name = "trout_line/index.html"
context_object_name = 'latest_chat_list'
def get_queryset(self):
"""Return the last five published questions."""
return Chat.objects.filter(start_date__lte=timezone.now()).order_by('-start_date')[:5]
and a template at [app]/templates/[app]/index.html.
When I run the server I receive the following message.
... path('', views.IndexView.as_view(), name='index'),
AttributeError: 'function' object has no attribute 'as_view'
I thought I followed the tutorial closely, but obviously I am missing something. Any help would be appreciated.
I am running Python 3.6 and Django 2.1.2 on Ubuntu 16