bruth/django-preserialize — pull request #11 by stargazer (2014-09-15 13:43:04+00:00)
Title: Django 1.7 incompatibility

In Django 1.7, Related Manager instances have been made callable (https://github.com/django/django/blob/master/django/db/models/fields/related.py#L651)

The consequence this has on ``django-preserialize``, is that the last *elif* in line 128 of method ``get_field_value``(https://github.com/bruth/django-preserialize/blob/master/preserialize/utils.py#L128) is never entered. All related manager instances will have been already picked up from the previous *if* statement, since they are now callables. And at that point, django raises a KeyError exception (exactly here: https://github.com/django/django/blob/master/django/db/models/fields/related.py#L654)

The solution is simple. Change the order of the last 2 conditional branches of method preserialize's ``utils.get_field_value`` method. Calling the callables directly should be the last resort, and used only when no other way of evaluating the value of a field works.

While hacking the code of ``django-preserialize`` to fix this issue, I figured out that the test suite was a bit inflexible, so I modified it. I've integrated dynamic instead of static fixtures, and added tox support. This makes for a way more flexible and powerful testing suite. For the record, now the tests pass for Django 1.5, 1.6 and 1.7 :-)

Using tox of course requires installing it first: ``pip install tox``