Error: 'dict' object has no attribute 'iteritems'
As you are in python3 , use dict.items()
instead of dict.iteritems()
iteritems()
was removed in python3, so you can't use this method anymore.
Take a look at Python 3.0 Wiki Built-in Changes section, where it is stated:
Removed
dict.iteritems()
,dict.iterkeys()
, anddict.itervalues()
.Instead: use
dict.items()
,dict.keys()
, anddict.values()
respectively.
AttributeError: 'MultiDict' object has no attribute 'iteritems' when moving from localhost to heroku
This was solved by creating a new class
from werkzeug.datastructures import ImmutableMultiDict
class Dict:
'''Wrapper klass because iteritems no longer available in Python3.7 dict'''
def __init__(self, mapping):
self.mapping = ImmutableMultiDict(mapping)
def iteritems(self):
return self.mapping.items()
def __getattr__(self, attr):
return getattr(self.mapping, attr)
def __iter__(self):
return dict.__iter__(self.mapping)
And then adding post = Dict(post)
prior to my process event.
AttributeError: 'dict' object has no attribute
It looks like you need to set the load_instance
Meta class attribute to True
, according to marshmallow-sqlalchemy
docs. As suggested by G. Anderson, you can try to print the update
object's type for confirmation, but it seems you are getting a default dict
as the deserialized data, instead of an instance of your Application
model, which could be achieved by doing the above-mentioned trick. The code could be written like this:
class ApplicationSchema(SQLAlchemyAutoSchema):
class Meta:
model = Application
include_relationships = True
load_instance = True
Related Topics
Is Distributing Python Source Code in Docker Secure
Pandas 'Count(Distinct)' Equivalent
Pandas Dataframe: Replace All Values in a Column, Based on Condition
How to Merge a Transparent Png Image with Another Image Using Pil
How to Pass a Method as a Parameter in Python
Using Logging in Multiple Modules
How to Overload _Init_ Method Based on Argument Type
Python MySQLdb: Library Not Loaded: Libmysqlclient.18.Dylib
Pandas: Setting No. of Max Rows
How to Find the Number of Arguments of a Python Function
How to Write Png Image to String with the Pil
Differencebetween Class and Instance Variables