Story short, I need to save in the history the changes made on a Many-To-Many fields of one of my models.
I can see from: https://github.com/Kyruus/django-simple-history/commit/5ba8d2b4d72819f154a11f297796e6a2bb7172bf that the M2M is supported. However whenever I make a change on a M2M field it changes as well in all the history, as if never has been changed. I'm new to django and python so maybe I'm missing something.
My models.py:
from django.db import models
from simple_history.models import HistoricalRecords
class Student(models.Model):
studentname = models.CharField(max_length=50, verbose_name='Name')
class ClassRoom(models.Model):
classname = models.CharField(max_length=50, verbose_name='Name')
students = models.ManyToManyField(Student)
history = HistoricalRecords()
My admin.py:
from django.contrib import admin
from school.models import Student, ClassRoom
from simple_history.admin import SimpleHistoryAdmin
class StudentAdmin(SimpleHistoryAdmin):
list_display = ('studentname',)
class ClassRoomAdmin(SimpleHistoryAdmin):
list_display = ('classname',)
admin.site.register(Student,StudentAdmin)
admin.site.register(ClassRoom, ClassRoomAdmin)
I installed the django-simple-history by:
>pip install django-simple-history