我是django的新手,当我从文档.d中学习django时,我尝试使用序列化程序和基于函数的视图制作api。这表明类型object'Questions'没有属性'objects'
models.py
class Questions:
title = models.CharField(max_length=40)
description = models.TextField(max_length=50)
status = models.CharField(default='inactive', max_length=30)
created_by = models.ForeignKey(User, null=True, blank=True, on_delete=models.CASCADE)
serializers.py
from rest_framework import serializers
from demoapp.models import Questions
class QuestionSerializer(serializers.ModelSerializer):
class Meta:
model = Questions
fields = (
'id',
'title',
'description',
'created_by',
)
urls.py
from django.urls import path
from demoapp.views import *
urlpatterns = [
path('poll', demoapp),
]
错误是: