错误不正确配置DetailView Django 1.8

时间:2017-08-03 17:16:14

标签: django detailsview

如何纠正错误?

看到我的错误:

ImproperlyConfigured at schedule/confirmed/c4e068dc-9e89-4fa5-9a66-cfb5ec6a306b/
ScheduleConfirmed is missing a QuerySet. Define ScheduleConfirmed.model, ScheduleConfirmed.queryset, or override ScheduleConfirmed.get_queryset().

并查看我的views.py

# views.py
class ScheduleConfirmed(generic.DetailView):
    modal = Schedule
    template_name = 'schedule-confirmed.html'

    # def get_context_data(self, **kwargs):
    #     context = super(ScheduleConfirmed, self).get_context_data(**kwargs)
    #     obj = self.object
    #     return context

my urls.py

#urls.py
    url(r'^schedule/confirmed/(?P<pk>[^/]+)/$', views.ScheduleConfirmed.as_view(), name='schedule_confirmed'),

my models.py

#models.py
class Schedule(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    creator = models.ForeignKey(User, related_name='schedule_creator')
    # ...

1 个答案:

答案 0 :(得分:4)

您的ScheduleConfirmed类属性中有拼写错误。只需将modal更改为model即可按预期工作。