Skip to content
This repository was archived by the owner on Oct 30, 2018. It is now read-only.
This repository was archived by the owner on Oct 30, 2018. It is now read-only.

show AttributeError: 'Options' object has no attribute 'get_all_related_objects' when execute "sudo bash restore-profiles.sh"  #351

Open
@jeffreyzh

Description

@jeffreyzh

the atc server show Internal Server Error when I execute sudo bash restore-profiles.sh 0.0.0.0:8000

pi@raspberrypi:~/workspace/atcui $ sudo python manage.py runserver 0.0.0.0:8000
Performing system checks...

System check identified no issues (0 silenced).
January 05, 2018 - 02:24:26
Django version 1.10, using settings 'atcui.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
Internal Server Error: /api/v1/profiles/
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py", line 39, in inner
    response = get_response(request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/atc_profile_storage/views.py", line 36, in profile_list
    if serializer.is_valid():
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/serializers.py", line 197, in is_valid
    self._validated_data = self.run_validation(self.initial_data)
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/serializers.py", line 391, in run_validation
    value = self.to_internal_value(data)
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/serializers.py", line 415, in to_internal_value
    fields = self._writable_fields
  File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/serializers.py", line 330, in _writable_fields
    field for field in self.fields.values()
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/serializers.py", line 323, in fields
    for key, value in self.get_fields().items():
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/serializers.py", line 896, in get_fields
    info = model_meta.get_field_info(model)
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/utils/model_meta.py", line 69, in get_field_info
    reverse_relations = _get_reverse_relationships(opts)
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/utils/model_meta.py", line 130, in _get_reverse_relationships
    for relation in opts.get_all_related_objects():
AttributeError: 'Options' object has no attribute 'get_all_related_objects'

so I think maybe the versions of these libraries do not fit,check my django and django-rest-framework version:

my django version is 1.10

pi@raspberrypi:~/workspace/augmented-traffic-control/utils $ pip show django
Name: Django
Version: 1.10
Summary: A high-level Python Web framework that encourages rapid development and clean, pragmatic design.
Home-page: http://www.djangoproject.com/
Author: Django Software Foundation
Author-email: foundation@djangoproject.com
License: BSD
Location: /usr/local/lib/python2.7/dist-packages
Requires:

the changelog show Django rest framework 3.2 has been supported from django 0.1.3,so my Django rest framework version is 3.2.0

pi@raspberrypi:~/workspace/augmented-traffic-control/utils $ pip show djangorestframework
Name: djangorestframework
Version: 3.2.0
Summary: Web APIs for Django, made easy.
Home-page: http://www.django-rest-framework.org
Author: Tom Christie
Author-email: tom@tomchristie.com
License: BSD
Location: /usr/local/lib/python2.7/dist-packages
Requires:

the versions of these libraries seems no problem. after that,I found django has a new meta API in the version of 1.10:
https://docs.djangoproject.com/en/1.10/ref/models/meta/get_all_related_objects was removed
but get_all_related_objects is using in django-rest-framework 3.2.0
https://github.com/encode/django-rest-framework/blob/3.2.0/rest_framework/utils/model_meta.py#L130

Is this the cause of the problem?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jeffreyzh

        Issue actions

          show AttributeError: 'Options' object has no attribute 'get_all_related_objects' when execute "sudo bash restore-profiles.sh" · Issue #351 · facebookarchive/augmented-traffic-control