Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError with django 1.11.5 models #542

Open
hadeelsharaf opened this issue Sep 21, 2017 · 2 comments
Open

AttributeError with django 1.11.5 models #542

hadeelsharaf opened this issue Sep 21, 2017 · 2 comments

Comments

@hadeelsharaf
Copy link

hadeelsharaf commented Sep 21, 2017

I had this error while creating a service to a django project :
AttributeError: 'Options' object has no attribute get_all_field_names
this is the code:

User = get_user_model()


class Container(DjangoComplexModel):
  class Attributes(DjangoComplexModel.Attributes):
      django_model = User
      django_exclude = [] 

this part of the tracback:

from .services import hello_world_service, app, HelloWorldService
File "/home/hadeel/projects/sadie_service/service/services.py", line 50, in <module>
  class Container(DjangoComplexModel):
File "/home/hadeel/.virtualenvs/sadie/lib/python3.5/site-packages/spyne/util/meta.py", line 66, in preparing_constructor
  return constructor(cls, name, bases, attributes)
File "/home/hadeel/.virtualenvs/sadie/lib/python3.5/site-packages/spyne/util/django.py", line 427, in __new__
  optional_relations=optional_relations)
File "/home/hadeel/.virtualenvs/sadie/lib/python3.5/site-packages/spyne/util/django.py", line 291, in map
  for field in self._get_fields(django_model, exclude):
File "/home/hadeel/.virtualenvs/sadie/lib/python3.5/site-packages/spyne/util/django.py", line 268, in _get_fields
  meta.get_all_field_names())
AttributeError: 'Options' object has no attribute 'get_all_field_names'
@egroeper
Copy link

egroeper commented Oct 6, 2017

I had the same error using the latest released spyne version (2.12.14), but with current master everything works fine.

Perhaps a new version of spyne should be released and published on pypi?

@igor-kremin
Copy link

https://stackoverflow.com/questions/40212969/options-object-has-no-attribute-get-all-field-names
Replace

unknown_fields_names = field_names.difference( 
    meta.get_all_field_names())

to

unknown_fields_names = field_names.difference(
    [f.name for f in meta.get_fields()])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants