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

GenericForeignKey problem #16

Open
ulladimil opened this issue Jan 10, 2019 · 0 comments
Open

GenericForeignKey problem #16

ulladimil opened this issue Jan 10, 2019 · 0 comments

Comments

@ulladimil
Copy link

ulladimil commented Jan 10, 2019

Hi, i use GenericForeignKey in my project and get the following error:

Traceback (most recent call last):
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
    response = get_response(request)
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 128, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/rest_framework/viewsets.py", line 103, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/rest_framework/views.py", line 483, in dispatch
    response = self.handle_exception(exc)
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/rest_framework/views.py", line 443, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/rest_framework/views.py", line 480, in dispatch
    response = handler(request, *args, **kwargs)
  File "/home/develop21/projects/eds_vodokanal_rnd/project/views.py", line 59, in list
    return Response(serializer.data)
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/rest_framework/serializers.py", line 765, in data
    ret = super(ListSerializer, self).data
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/rest_framework/serializers.py", line 262, in data
    self._data = self.to_representation(self.instance)
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/rest_framework/serializers.py", line 683, in to_representation
    self.child.to_representation(item) for item in iterable
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/django/db/models/query.py", line 272, in __iter__
    self._fetch_all()
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/django/db/models/query.py", line 1182, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/django/db/models/query.py", line 63, in __iter__
    obj = model_cls.from_db(db, init_list, row[model_fields_start:model_fields_end])
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/django/db/models/base.py", line 507, in from_db
    new = cls(*values)
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/django/db/models/base.py", line 497, in __init__
    post_init.send(sender=cls, instance=self)
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 178, in send
    for receiver in self._live_receivers(sender)
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 178, in <listcomp>
    for receiver in self._live_receivers(sender)
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/fieldsignals/signals.py", line 79, in post_init_closure
    self.get_and_update_changed_fields(receiver, instance, fields)
  File "/home/develop21/projects/eds_vodokanal_rnd/.venv/lib/python3.6/site-packages/fieldsignals/signals.py", line 137, in get_and_update_changed_fields
    if field.attname in deferred_fields:
AttributeError: 'GenericForeignKey' object has no attribute 'attname'
  • Django==2.0.10
  • django-fieldsignals==0.4.0
# models.py

class Comment(models.Model):

    object_id = models.PositiveIntegerField()

    object_ct = models.ForeignKey(
        'contenttypes.ContentType',
        on_delete=models.PROTECT)

    object_nk = GenericForeignKey('object_ct', 'object_id')
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

1 participant