2020腾讯云10周年活动,优惠非常大!(领取2860元代金券),
地址:https://cloud.tencent.com/act/cps/redirect?redirect=1040
地址:https://cloud.tencent.com/act/cps/redirect?redirect=1040
2020阿里云最低价产品入口,含代金券(新老用户有优惠),
入口地址:https://www.aliyun.com/minisite/goods
入口地址:https://www.aliyun.com/minisite/goods
When querying my API with
format=json
I get the following error:Django Serialize Dict Object Has No Attribute Meta Install Developer Tools Im sure I already following your instruction step-by-step, but still no good, please have a look. Are you saying you changed it to ratings profile because your models are in your profile app or because your template is in your profile app Or neither and I am just. Django Serialize Dict Object Has No Attribute Meta. AttributeError: 'dict' object has no attribute 'statuscode'. There is some conflict between the version you mention (1.3 beta 1 SVN-15045) and what seems to be indicated by the file names (django-1.2.3). Which is it, or have you really put 1.3 beta in a directory named django-1.2.3? Well if it has something to do with initializing a new database name via 'file.txt' which you refer through a. RE: Variable table name inside class By Joncoragladys - 7 hours ago When declaring a class variable in PHP OOP, they are called class member variables or class properties. 'QuerySet' object has no attribute 'serialize' models.py import json from django.core.serializers import serialize from django.db import models from django.conf import settings # Create your models here.
Interestingly enough it doesn't happen with the Django Rest Framework API UI. Only when
format=json
. Here is my list method:
Django Serialize Dict Object Has No Attribute Meta Download
And my serializer:
Traceback:
Recommend:python - Django REST framework: AttributeError: object has no attribute 'serializer'
6 on Mac OS v.10.10.3, Django1.6.5 and djangorestframework3.1.1. I'm trying to write a couple of tests against Django REST framework. I have a dummy test view for the API: class TestApiView(APIView): def get(self, request, format=No
What gives?
pythonjsondjangodjango-rest-framework|
this questionedited Jul 17 '14 at 21:00 asked Jul 17 '14 at 20:52 hanleyhansen 3,021 3 25 59 2 What is the full traceback? You probably shouldn't use the name
list
for your function as that masks the built-in type. The object in your exception is the actual list
type![Object Object](https://i.stack.imgur.com/2hdbq.png)
list
is the expected method for that request. I'm overriding list
in my case. Traceback added. – hanleyhansen Jul 17 '14 at 20:59 Right; as a method is namespaced that should be okay. – Martijn Pieters♦ Jul 17 '14 at 21:01 That's an awfully short traceback with no visible correlation whatsoever with the exception, though. – Martijn Pieters♦ Jul 17 '14 at 21:06 @MartijnPieters hence my sadness =( – hanleyhansen Jul 17 '14 at 21:06 | 1 Answers
1
When you use
many=True
it serializes several objects and puts them in a list. As the JSONResponse
class expects to be passed a dict (unless also passed safe=False
), I'm guessing your Response
class does as well.|
this answer answered Jul 17 '14 at 21:12 Ross Ridge 20.6k 2 26 57 I took another look at the
Response
class. It's just a subclass of SimpleTemplateResponse
. However, I did notice in the documentation that the content_type
parameter is supposed to be set automatically if properly determined by content negotiation. In other words, something in the content negotiation seems to be off because if i pass the content_type
it works. – hanleyhansen Jul 17 '14 at 21:24 As I recall you can perfectly pass lists to the response-class in DRF. – Denis Cornehl Jul 18 '14 at 7:33 1 It does seem you're supposed to be able to. A simple way to test whether the list being passed to Django Serialize Dict Object Has No Attribute Metal
Response
is the list being complained about in the exception would be to make it a dict and see what happens. Eg. Response(dict(enumerate(serializer.data)))
– Ross Ridge Jul 18 '14 at 13:28 @RossRidge Passing a dict works fine. Something like Django Serialize Dict Object Has No Attribute Meta In English
Response({'data': serializer.data})
. – hanleyhansen Jul 18 '14 at 13:56 Have you had any luck trying to get a full traceback? Done the obvious like set DEBUG=True
Django Serialize Dict Object Has No Attribute _meta
in you Django settings? I think we'll need the full traceback to figure out why it doesn't work with lists. – Ross Ridge Jul 18 '14 at 14:57 | show more commentDjango Serialize Dict Object Has No Attribute Meta List
Recommend:python - Django REST framework: AttributeError: Serializer object has no attribute 'Meta'python# -*- coding: utf-8 -*-from django.db import modelsclass StationReport(models.Model): water_level = models.IntegerField(max_length=5, blank=False) user_name = models.CharField(max_length=256, blank=False) email_addres
Recommend:python - Django REST framework: AttributeError: Serializer object has no attribute 'Meta'
python# -*- coding: utf-8 -*-from django.db import modelsclass StationReport(models.Model): water_level = models.IntegerField(max_length=5, blank=False) user_name = models.CharField(max_length=256, blank=False) email_addres