Skip to content

Commit

Permalink
Merge 795f813 into 0001c47
Browse files Browse the repository at this point in the history
  • Loading branch information
macro1 committed Oct 8, 2014
2 parents 0001c47 + 795f813 commit 8970a74
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ tip (unreleased)
----------------
- Removed some incompatibilities with non-default admin sites (gh-92)
- Fixed error caused by ``HistoryRequestMiddleware`` during anonymous requests (gh-115 fixes gh-114)
- Added workaround for clashing related historical accessors on User (gh-121)

1.5.0 (2014-08-17)
------------------
Expand Down
7 changes: 5 additions & 2 deletions simple_history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ def python_2_unicode_compatible(klass):
class HistoricalRecords(object):
thread = threading.local()

def __init__(self, verbose_name=None, bases=(models.Model,)):
def __init__(self, verbose_name=None, bases=(models.Model,),
user_related_name=None):
self.user_set_verbose_name = verbose_name
self.user_related_name = user_related_name
try:
if isinstance(bases, basestring):
raise TypeError
Expand Down Expand Up @@ -178,7 +180,8 @@ def get_instance(self):
return {
'history_id': models.AutoField(primary_key=True),
'history_date': models.DateTimeField(),
'history_user': models.ForeignKey(user_model, null=True),
'history_user': models.ForeignKey(
user_model, null=True, related_name=self.user_related_name),
'history_type': models.CharField(max_length=1, choices=(
('+', 'Created'),
('~', 'Changed'),
Expand Down
14 changes: 14 additions & 0 deletions simple_history/tests/external/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
from __future__ import unicode_literals

from django.db import models
from simple_history.models import HistoricalRecords

from .model2 import ExternalModel2
from .model4 import ExternalModel4


class Poll(models.Model):
"""Test model for same-named historical models
This model intentionally conflicts with the 'Polls' model in 'tests.models'.
"""
history = HistoricalRecords(user_related_name='+')

class Meta:
app_label = 'external'

0 comments on commit 8970a74

Please sign in to comment.