Closed tysonclugg closed 10 years ago
I understand the problem. This is definitely something I haven't thought of or tried to do in practice before. But, I don't think I like the solution on first sight. Maybe there is a cleaner way to do this easily. I will give it a better thought in the next few days.
Thanks
This LastUserField is not used only to track log entries it can be used standalone. And in a case where it's used standalone, with this fix it will still cause a problem. Also I don't particularly like the approach of doing string comparisons to check for the case. I'm cooking something up that should fix the problem.
Actually, when using the LastUserField on a custom auth user it won't be a problem because you can set the 'to' argument manually like on a ForeignKey . I fixed this issue with my last commit. I will do a release on pypi tonight. However, I'm not completely satisfied even with the solution that I came up with cause it's comparing strings again. But it is what it is. It's hard to do it otherwise and I think the solution I came up with is not very prone to breakage because of a change in another place (say the naming convention in the audit log).
Thanks for reporting the problem and your solution
This request I believe was closed by 529327db618d63dccbce6f682cb27ec99c6997af.
We were getting an error when using "audit_log = AuditLog()" on a custom user model (inheriting from django.contrib.auth.mdoels.AbstractBaseUser):
The quick and dirty fix was to compare the kwargs['related_name'] with the relation target (to) and use "self" instead. We're open to alternate fixes...