Skip to content

Conversation

@jplock
Copy link

@jplock jplock commented Feb 5, 2016

This is related to django/django#4241

rest_framework/utils/model_meta.py:83: RemovedInDjango20Warning: Usage of field.rel has been deprecated. Use field.remote_field instead.
  while pk.rel and pk.rel.parent_link:
rest_framework/utils/model_meta.py:92: RemovedInDjango20Warning: Usage of field.rel has been deprecated. Use field.remote_field instead.
  for field in [field for field in opts.fields if field.serialize and not field.rel]:
rest_framework/utils/model_meta.py:107: RemovedInDjango20Warning: Usage of field.rel has been deprecated. Use field.remote_field instead.
  for field in [field for field in opts.fields if field.serialize and field.rel]:
rest_framework/utils/model_meta.py:147: RemovedInDjango20Warning: Usage of field.rel has been deprecated. Use field.remote_field instead.
  to_many=relation.field.rel.multiple,
rest_framework/utils/model_meta.py:163: RemovedInDjango20Warning: Usage of field.rel has been deprecated. Use field.remote_field instead.
  (getattr(relation.field.rel, 'through', None) is not None) and
rest_framework/utils/model_meta.py:164: RemovedInDjango20Warning: Usage of field.rel has been deprecated. Use field.remote_field instead.
  not relation.field.rel.through._meta.auto_created

I'm not sure how best to handle this for versions prior to Django 1.9

@xordoquy
Copy link
Contributor

xordoquy commented Feb 6, 2016

Thanks for the PR. Unfortunately this breaks Django < 1.9 compatibility.
This can be solved with a compatibility function (compat.py) to handle the various cases.

@jplock
Copy link
Author

jplock commented Feb 6, 2016

@xordoquy thanks for the feedback, I added a compatibility function and the tests are now passing.

while get_remote_field(pk) and get_remote_field(pk).parent_link:
# If model is a child via multi-table inheritance, use parent's pk.
pk = pk.rel.to._meta.pk
pk = get_remote_field(pk).to._meta.pk
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we instead have this set in a var after line 83? remote_field = get_remote_field(pk) and use throughout?

@lovelydinosaur
Copy link
Contributor

Looks like this just needs bringing up to date with master.
Milestoning to keep it on my radar.

@lovelydinosaur
Copy link
Contributor

Thanks for raising this @jplock. Now resolved!

@jplock
Copy link
Author

jplock commented Jun 2, 2016

Thanks for fixing this. Once I tried to implement @jpadilla's suggestion, I got stuck and distracted.

@jplock jplock deleted the jp-gh3729 branch June 2, 2016 13:48
@lovelydinosaur
Copy link
Contributor

S'all good. We got there in the end!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants