wlanslovenija / django-tastypie-mongoengine

MongoEngine support for django-tastypie.
Other
73 stars 59 forks source link

Error with recent mongoengine versions #95

Open apolkosnik-old opened 8 years ago

apolkosnik-old commented 8 years ago

After upgrading to mongoengine 0.10.x I get this error:

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/data/crits/crits/urls.py", line 46, in from crits.actors.api import ActorResource, ActorIdentifierResource File "/data/crits/crits/actors/api.py", line 11, in class ActorResource(CRITsAPIResource): File "/Library/Python/2.7/site-packages/tastypie_mongoengine/resources.py", line 225, in new new_class.base_fields.update(new_class.get_fields(include_fields, excludes)) File "/Library/Python/2.7/site-packages/tastypie_mongoengine/resources.py", line 725, in get_fields 'help_text': f.help_text , AttributeError: 'StringField' object has no attribute 'help_text'

If I comment out the line 725 in resources.py, it fixes it for me, but perhaps there's something that I'm missing in my app, that could fix it.

Thanks, -A

apolkosnik-old commented 8 years ago

Perhaps changing the code in resources.py to something like this would help:

            kwargs = {
                'attribute': name,
                'unique': f.unique or primary_key,
                'null': not f.required and not primary_key,
            }

            if hasattr(f, 'help_text'):
                kwargs['help_text'] = f.help_text

It fixes it for me. Thanks!