From ece376e0bcf00ca476502ed213b1676c132165b3 Mon Sep 17 00:00:00 2001 From: Orlando Jimenez Date: Fri, 12 Sep 2014 07:54:49 -0430 Subject: [PATCH] if attribute is not in model attributes on create, raise a error --- eav/managers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eav/managers.py b/eav/managers.py index 315c28c..e9a4d4e 100644 --- a/eav/managers.py +++ b/eav/managers.py @@ -163,12 +163,16 @@ def create(self, **kwargs): #attributes = config_cls.get_attributes() prefix = '%s__' % config_cls.eav_attr + attributes_name = [x.name for x in config_cls.get_attributes()] new_kwargs = {} eav_kwargs = {} for key, value in kwargs.iteritems(): if key.startswith(prefix): - eav_kwargs.update({key[len(prefix):]: value}) + if key[len(prefix):] in attributes_name: + eav_kwargs.update({key[len(prefix):]: value}) + else: + raise AttributeError("Attribute %s not in model attributes"%(key[len(prefix):],)) else: new_kwargs.update({key: value})