Skip to content

Several 'RemovedInDjango20Warning's with Django 1.11 (field.rel, ForeignObjectRel.to) #242

Closed
@edmorley

Description

@edmorley

Hi!

When running our test suite with Python warnings enabled (eg PYTHONWARNINGS=once pytest), we get the following deprecation warnings:

  .../site-packages/graphene_django/utils.py:61: RemovedInDjango20Warning: Usage of field.rel has been deprecated. Use field.remote_field instead.
    if hasattr(field, 'rel'):
  .../site-packages/graphene_django/utils.py:63: RemovedInDjango20Warning: Usage of ForeignObjectRel.to attribute has been deprecated. Use the model attribute instead.
    return field.rel.to

These line numbers correspond to:
https://github.com/graphql-python/graphene-django/blob/v1.3/graphene_django/utils.py#L61
https://github.com/graphql-python/graphene-django/blob/v1.3/graphene_django/utils.py#L63

The deprecation docs for this are here:
https://docs.djangoproject.com/en/1.11/releases/1.9/#field-rel-changes

I'm presuming the solution would be to either:

  1. Drop support for Django 1.6/1.7 entirely
  2. Invert the conditional, such that it does hasattr(field, 'related_model') and if not found then falls back to field.rel.to.

Given Django <1.8 is EOL and has security vulnerabilities, I'd lean towards solution (1).

This was using:

  • graphene-django 1.3
  • graphene 1.4.1
  • Django 1.11.4
  • Python 2.7.13

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

    Issue actions