Django 抛出下一个异常:
restframework 'tuple' 对象没有属性 '_meta'
模型
class BDetail(models.Model):
lat = models.FloatField(blank=True, null=True)
lng = models.FloatField(blank=True, null=True)
class Meta:
# managed = False
db_table = 'b_detail'
看法
from .models import BDetail
from .serializers import BDetailSerializer
from rest_framework import viewsets
class BDetailList(viewsets.ModelViewSet):
queryset = BDetail.objects.all()
serializer_class = BDetailSerializer
网址
from django.conf.urls import url, include
from bdetail import views
from rest_framework import routers
router = routers.DefaultRouter()
router.register(r'bdetail', views.BDetailList)
urlpatterns = [
url(r'^', include(router.urls), name='bdetail')
]
序列化器
from .models import BDetail
from rest_framework import serializers
class BDetailSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = BDetail,
fields = ('lat', 'lng')
环境:
请求方法:GET 请求地址:http ://apiix.verinmuebles.dev/v1/bdetail/
追溯:
内部 39 中的文件“/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/django/core/handlers/exception.py”。 response = get_response(request)
_get_response 187 中的文件“/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/django/core/handlers/base.py”。响应 = self.process_exception_by_middleware(e,请求)
_get_response 185 中的文件“/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/django/core/handlers/base.py”。 response = Wrapped_callback(request, *callback_args, **callback_kwargs)
Wrapped_view 中的文件“/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/django/views/decorators/csrf.py” 58. return view_func(*args, **kwargs )
视图 87 中的文件“/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/viewsets.py”。 return self.dispatch(request, *args, **kwargs )
调度 474 中的文件“/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/views.py”。响应 = self.handle_exception(exc)
handle_exception 434 中的文件“/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/views.py”。self.raise_uncaught_exception(exc)
调度 471 中的文件“/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/views.py”。 response = handler(request, *args, **kwargs)
列表 45 中的文件“/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/mixins.py”。返回 self.get_paginated_response(serializer.data)
数据 701 中的文件“/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/serializers.py”。 ret = super(ListSerializer, self).data
数据 240 中的文件“/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/serializers.py”。self._data = self.to_representation(self.instance)
to_representation 619 中的文件“/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/serializers.py”.self.child.to_representation(item) 用于可迭代中的项目
to_representation 460 中的文件“/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/serializers.py”。fields = self._readable_fields
获取35中的文件“/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/django/utils/functional.py” 。 res = instance. dict [self.name] = self.func(instance)
_readable_fields 354 中的文件“/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/serializers.py”。 self.fields.values() 中的字段
字段 340 中的文件“/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/serializers.py”。对于 self.get_fields().items( ):
get_fields 946 中的文件“/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/serializers.py”。 info = model_meta.get_field_info(model)
get_field_info 36 中的文件“/var/www/verinmuebles/current/Env/api/local/lib/python2.7/site-packages/rest_framework/utils/model_meta.py”。 opts = model._meta.concrete_model._meta
异常类型:/v1/bdetail/ 处的 AttributeError 异常值:“元组”对象没有属性“_meta”