Django Serialize Dict Object Has No Attribute Meta

here is my models.py from django.db import models class country (models.Model): country_name = models.CharField(max_length=200, null=True) def __str__(self): return self.country_name class state (models.Model): state_name = models.CharField(max_length=200, null=True) country = models.ForeignKey(country, on_delete=models.CASCADE, null=True) def __str__(self): return self.state_name class city (models.Model): city_name = models.CharField(max_length=200, null=True) country = models.ForeignKey(country, on_delete=models.CASCADE, null=True) state = models.ForeignKey(state, on_delete=models.CASCADE, null=True) def __str__(self): return self.city_name class publication(models.Model): title= models.CharField(max_length=300, null=True) country=models.ForeignKey(country, on_delete=models.CASCADE, null=True) state=models.ForeignKey(state, on_delete=models.CASCADE, null=True) city=models.ForeignKey(city, on_delete=models.CASCADE, null=True) def __str__(self): return self.title here is my seralizers.py from rest_framework import routers, serializers, viewsets from .models import * from django.contrib.auth.models import User from rest_framework import permissions class publicationSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = publication fields = '__all__' here is my view.py from django.shortcuts import render from django.http import HttpResponse, JsonResponse from .models import * from .serializers import * from rest_framework.views import APIView from rest_framework.response import Response from rest_framework import status,mixins,generics from django.http import Http404 from rest_framework import renderers class SnippetHighlight(APIView): def get(self,request): queryset = publication.objects.select_related('country','state','city') serializer_class = publicationSerializer(queryset,many=True) return Response(serializer_class.data) here is my urls.py from django.conf.urls import url, include from django.contrib import admin from rest_framework.urlpatterns import format_suffix_patterns from api.models import * from api import views # from api.serializers import UserSerializer urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^snippets/', views.SnippetHighlight.as_view()), # url(r'^users/$', views.UserList.as_view()), # ...

Django Serialize Dict Object Has No Attribute Meta 我试图在 Django 中使用 39 dict 39; object has Any relationships such as foreign keys on the model will be. Serializing objects. We can now use CommentSerializer to serialize a comment, or list of comments. Elif isinstance(attribute, dict): # Recursively deal with items in dictionaries. Like Django's Model and ModelForm classes, the inner Meta class on serializers does not implicitly.