vvangelovski / django-audit-log

Audit log for your Django models
Other
232 stars 94 forks source link

audit_log, south and OneToOneField #7

Closed rossowl closed 9 years ago

rossowl commented 13 years ago

Hi, I found the problem when using OneToOneField and south. The first migration create the field unique=True and every next migration is trying to set unique to False. And over and over. Here is patch:

diff --git a/audit_log/models/managers.py b/audit_log/models/managers.py
index ee3defd..1c04825 100644
--- a/audit_log/models/managers.py
+++ b/audit_log/models/managers.py
@@ -101,6 +101,9 @@ class AuditLog(object):

                     field.__class__ = models.IntegerField

+                if isinstance(field, models.OneToOneField):
+                    field.__class__ = models.ForeignKey
+
                 if field.primary_key:
                     field.serialize = True

-- 
1.7.5.4
mfwarren commented 12 years ago

I ran into this as well. would be great to have this fixed.

We have audit_log on a UserProfile model class with a OneToOneField back to User and using South to manage schema migrations.