gadventures / django-fsm-admin

Mixin and template tags to integrate django-fsm transitions into the django admin.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Django 1.10 warning get_field_by_name

bschellekens opened this issue · comments

Hi,
With lots of pleasure I'm using fsm-admin, great stuff! I notice that there is a minor warning when moving to 1.10. Any plans to adjust the code?

fsm_admin/mixins.py:78: RemovedInDjango110Warning: 'get_field_by_name is an unofficial API that has been deprecated. You may be able to replace it with 'get_field()' with: return self.model._meta.get_field_by_name(fsm_field_name)[0]

This occurs in two area's of the code in the module mixins.py

  1. fms_field_instance (code line 78).
  2. _get_possible_transitions (code line 224)

Solution: replace get_fields_by_name(field)[0] by get_fields(field)

Shall I post a pull request or would you rather do this?

@bschellekens we're happy to review and accept pull requests! Does this removal affect support for previous versions of Django?

The new _meta API was introduced in 1.8 - https://docs.djangoproject.com/en/1.8/ref/models/meta/, so it will break older versions.

Also, the new method is get_field, not get_fields.

With the release of Django 1.10, this is now breaking peoples code.

I suggest we start with #59, so we know what is breaking.

This package needs a compatibility plan :)

+1 Didn't see this issue before we upgraded to 1.10. Ended up monkey-patching the missing methods back in to get things working again.

Still happening.