我正在构建一个用于管理图书库的应用,我需要从sqlite3数据库中检索数据
我正在使用Django 2.2。我读了一些书,他们像这样:
class LanguageView(viewsets.ModelViewSet):
queryset = Language.objects.get()
serializer_class = LanguageSerializer
class Language(models.Model):
name = models.CharField(max_length=50)
paradigm = models.CharField(max_length=50)
我的序列化器类是
class LanguageSerializer(serializers.ModelSerializer):
class Meta:
model = Language
fields = ('id','name','paradigm')
我希望得到{"id":1,"name":"Learning Python", "paradigm":"object-oriented"}
但它会引发错误:Class 'Language' has no 'objects' member