rpkilby / jsonfield

A reusable Django model field for storing ad-hoc JSON data
MIT License
1.16k stars 271 forks source link

Raise error with GenericForeignKeys #190

Closed tomhamiltonstubber closed 7 years ago

tomhamiltonstubber commented 7 years ago

As per the issue #189, creating an object that has both a JSONField and a GenericForeignKey raises the issue here, as per below:

  File "/home/tom/django-jsonfield/env/lib/python3.6/site-packages/django/db/models/options.py", line 890, in _property_names
    dir(self.model) if isinstance(getattr(self.model, attr), property)
  File "/home/tom/django-jsonfield/env/lib/python3.6/site-packages/django/db/models/options.py", line 890, in <setcomp>
    dir(self.model) if isinstance(getattr(self.model, attr), property)
  File "/home/tom/django-jsonfield/jsonfield/subclassing.py", line 35, in __get__
    raise AttributeError('Can only be accessed via an instance.')
AttributeError: Can only be accessed via an instance.

My PR duplicates the error, but I haven't figured out how to solve.

samuelcolvin commented 7 years ago

@dmkoch a fix for this would be great, it's stopping us moving to django 1.11.