question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Django 1.10rc1 'ForeignKey' object has not attribute 'related'

See original GitHub issue

When attempting to use the json_api renderer with Django 1.10rc1 I’m getting a strange error about field.related not being set. It appears this was a private attribute that was deprecated in 1.8 and has finally been removed.

Partial trace

lib/python3.5/site-packages/rest_framework_json_api/utils.py", line 194, in get_related_resource_type
    relation_model = parent_model_relation.field.related.model
AttributeError: 'ForeignKey' object has no attribute 'related'

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
raphdgcommented, Aug 11, 2016

Here’s some more info about this, I’ve encountered the same issue when serializing results from a model with a ManyToMany relationship.

  File "./env/lib/python2.7/site-packages/rest_framework_json_api/utils.py", line 194, in get_related_resource_type
    relation_model = parent_model_relation.field.related.model
AttributeError: 'ManyToManyField' object has no attribute 'related'

I was using Django 1.10. Reverting Django to the 1.9, I got this deprecation warning

./env/lib/python2.7/site-packages/rest_framework_json_api/utils.py:194: RemovedInDjango110Warning: Usage of field.related has been deprecated. Use field.remote_field instead.
  relation_model = parent_model_relation.field.related.model
0reactions
jerelcommented, Aug 18, 2016

Thanks for confirming. We’ll try to get 2.1.0 out shortly

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django 1.10 release notes
These release notes cover the new features, as well as some backwards incompatible changes you'll want to be aware of when upgrading from...
Read more >
django Changelog - pyup.io
Fixed a regression in Django 4.1 where the app registry was not populated ... Related widget wrappers now have a link to object's...
Read more >
Django: docs/releases/1.10.txt | Fossies
InlineModelAdmin.classes>` attribute allows specifying 87 classes on ... 89 90 * If a user doesn't have the add permission, the ``object-tools`` block on...
Read more >
[Answered]-Django: Forbidden (CSRF cookie not set.)
I am having a problem with "CSRF cookie not set". All I need is that the external billing platform send the update to...
Read more >
CHANGES.md · 2d295a4be92894d18d71512548db8629a3ed4b50 ...
Add documentation on how to connect Django with Synapse using OpenID Connect and ... object has no attribute 'xpath'" and "ValueError: Unicode strings...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found