This tells Django how to calculate the URL for an object. Django uses this in its admin interface, and any time it needs to figure out a URL for an object. You tell Django that it’s a proxy model by setting the proxy attribute of the Meta class to True. And serialization. These are features which normal Python class. Python - Django REST framework: AttributeError: object has no attribute 'serializer' python - AttributeError: 'NoneType' object has no attribute 'defaultmanager' when running lettuce with django rest framework; python - django rest framework 'QuerySet' object has no attribute 'meta' python - 'dict' object has no attribute 'pk' Django Rest.
- Django Serialize Dict Object Has No Attribute Meta 1
- Django Serialize Dict Object Has No Attribute Meta Download
- Django Serialize Dict Object Has No Attribute Meta Key
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
Im using Django Rest API Framework, I want to upload multiple images for a single project using Angular js.
Here's my model:
![Serialize Serialize](https://images2.programmersought.com/384/72/722fe0acc2e69c904b4c7bb71e792008.png)
I have this serializers:
In my view I got this inside my viewsets.ModelViewSet
The variable photo_array contains:
[{'project': u'1', 'images': {u'name': u'test-image.png', u'lastModifiedDate': u'2015-04-22T08:51:11.000Z', u'webkitRelativePath': u', u'lastModified': 1429692671000, u'type': u'image/png', u'size': 43152}}, {'project': u'1', 'images': {u'name': u'test.png', u'lastModifiedDate': u'2015-04-08T08:35:17.000Z', u'webkitRelativePath': u', u'lastModified': 1428482117000, u'type': u'image/png', u'size': 127433}}]
But it gives me an error 'dict' object has no attribute 'pk'
Did my photo_array variable cause this problem?.
pythondjangoangularjsrestdjango-rest-framework|
this question asked May 5 '15 at 9:24 ring_22 42 8 It would be incredibly useful if you included the traceback for the error in your post. – Kevin Brown May 5 '15 at 22:52 |
2 Answers
2
I think you should update your UploadSerializer with id field
|
this answer answered May 5 '15 at 9:40 partha 1 1 2 Hi partha and welcome to StackOverflow. Could you please elaborate a bit on your answer, adding perhaps a code sample and an explanation to help other users understand why/how this will solve the problem? – Christina May 5 '15 at 9:53 Hi partha thanks for the answer. You mean adding 'id' to the fields in UploadSerializer
Django Serialize Dict Object Has No Attribute Meta 1
?. – ring_22 May 5 '15 at 10:00 use project_id key instead of project '[{'project': u'1',' and let m know – jatin May 5 '15 at 10:31 yes, add 'id' field to your uploadserializer. – partha May 7 '15 at 4:59 |Without a traceback, I can only take an educated guess as to what the issue actually is.
Recommend:python - django rest framework 'QuerySet' object has no attribute '_meta'
es me AttributeError: 'QuerySet' object has no attribute '_meta' error. Below id my code models.py class Book(models.Model): name = models.CharField(max_length=200, null=False, blank=False) cover = models.ImageField(upload_to=Rename Mengubah ukuran subtitle di tanaka t21.
You are using a standard
ModelSerializer
and you are allowing Django REST framework to generate your fields for you. You can introspect the generated fields by printing the output of repr(UploadSerializer())
, but they should look something like this:With those fields, a typical dictionary that would be passed back from the serializer should look something like
You'll notice that this is completely different from what you are passing in. You are passing in the data that would match a serializer that looks like
Django Serialize Dict Object Has No Attribute Meta Download
So that does answer your secondary question
Did my photo_array variable cause this problem?
Most likely. Now, I don't actually know what your issue is. It sounds like you are passing a dictionary into a
PrimaryKeyRelatedField
, but your serializers don't actually match up.|
![Django serialize dict object has no attribute metallica Django serialize dict object has no attribute metallica](https://d3by36x8sj6cra.cloudfront.net/assets/images/book/large/9780/0717/9780071772747.jpg)
Django Serialize Dict Object Has No Attribute Meta Key
Recommend:python - Django rest framework apiMANUAL FOR SUPER 7 LATHE (POWER CROSS FEED) No. S.273 W Ref: 3526 This is a manual for the operation, installation and maintenance of a myford Super 7 lathe with a power cross feed. Myford super 7 gearbox manual. Page 1 1/4' B.S.F. Screws, return the metric screws to us for exchange. QUICK CHANGE GEARBOX Nos, 1480 (ML7) and 1680 (ML7-R) and Super 7) INSTRUCTIONS FOR INSTALLATION AND OPERATION WITH PICTORIAL PARTS LIST Myford Ltd, Wilmot Lane, Chilwell Road, Beeston, Nottingham NG9 I ER Telephone: 01 15 925 4222.it to just send to me in Json 'Hello world' without writing or without opening a table in the DB this is my code: @api_view()def about(request): return Response({'message': 'Hello, world!'}) i put it in view.py what more i should do t
Recommend:python - Django rest framework api
MANUAL FOR SUPER 7 LATHE (POWER CROSS FEED) No. S.273 W Ref: 3526 This is a manual for the operation, installation and maintenance of a myford Super 7 lathe with a power cross feed. Myford super 7 gearbox manual. Page 1 1/4' B.S.F. Screws, return the metric screws to us for exchange. QUICK CHANGE GEARBOX Nos, 1480 (ML7) and 1680 (ML7-R) and Super 7) INSTRUCTIONS FOR INSTALLATION AND OPERATION WITH PICTORIAL PARTS LIST Myford Ltd, Wilmot Lane, Chilwell Road, Beeston, Nottingham NG9 I ER Telephone: 01 15 925 4222.
it to just send to me in Json 'Hello world' without writing or without opening a table in the DB this is my code: @api_view()def about(request): return Response({'message': 'Hello, world!'}) i put it in view.py what more i should do t