django-simple-history

I get a type error with django-simple-history


This only seems to happen when I try to view some model objects. I get the following when I visit the history page for an object in the admin page:

__str__ returned non-string (type NoneType)

Full traceback: https://dpaste.com/EQMTDXK5H

EDIT: Looks like the issue was that the str for my model was returning an integer, which Django seemed happy with but django-simple-history was not. I added str() into my str to convert the integer to a string and all works now.


Solution

  • Looking at the code here and here

    Seems that the __str__ of the HistoryRecords module looks for the __str__ of your model to build it's own, and also uses it on the template for the history build.

    Check that your model has __str__ implemented.