ImproperlyConfigured DetailView is missing a QuerySet


I’m trying to use a generic DetailView for my model and I’m getting the error: ClassroomDetailView is missing a QuerySet. Define ClassroomDetailView.model, ClassroomDetailView.queryset, or override ClassroomDetailView.get_queryset(). I’ve seen other people with a similar error and the solution is typically that their url pattern didn’t properly reference their view name. I can’t find any typos like that for mine though. My understanding is that the generic DetailView does not require a querset.
class Classroom(models.Model):
    classroom_name = models.CharField(max_length=10)
    course = models.ForeignKey(Course, on_delete=models.CASCADE)

    def __str__(self):
        return self.classroom_name
class ClassroomDetailView(generic.DetailView):
    model: Classroom
app_name = 'gradebook'
urlpatterns = [
    path('', views.IndexView.as_view(), name='index'),
    path('signup/', SignUpView.as_view(), name='signup'),
    path('courses/',, name='courses'),
    path('classroom/', views.classroom, name='classroom'),
         views.ClassroomDetailView.as_view(), name='classdetail'),
    path('addstudent/<int:classroom_id>/', views.addstudent, name='addstudent'),
         views.addmultistudent, name='addmultistudent'),
    path('objective/<int:course_id>/', views.addobjective, name='addobjective'),
         views.addassessment, name='addassessment'),


You need to use "=" instead of ":":

class ClassroomDetailView(generic.DetailView):
    model = Classroom
Leave a Reply

Your email address will not be published. Required fields are marked *