You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The SimpleHistoryAdmin.history_view assumes that the user model associated with the history_user is the one specified in AUTH_USER_MODEL, disregarding any class provided in the HistoricalRecords.user_model argument.
fromdjango.dbimportmodelsfromsimple_history.modelsimportHistoricalRecordsclassPollUser(models.Model):
user_id=models.ForeignKey('auth.User')
# Only PollUsers should be modifying a PollclassPoll(models.Model):
question=models.CharField(max_length=200)
pub_date=models.DateTimeField('date published')
changed_by=models.ForeignKey(PollUser)
history=HistoricalRecords(user_model=PollUser)
@propertydef_history_user(self):
returnself.changed_by@_history_user.setterdef_history_user(self, value):
self.changed_by=value
Instantiate a new Poll object while specifying the user responsible for the modification.
Navigate to http://<HOSTNAME>/admin/<APP>/poll/<PK>/history/ (retrieve from reverse(f"admin:{obj._meta.app_label}_{obj._meta.model_name}_history", args=[quote(obj.pk)])).
Select the link under the "Changed By" column.
ISSUE: Redirects to the auth.user change URL instead of the appropriate admin URL for the PollUser
Expected behavior
Using the PollUser admin change URL (using the class provided in the HistoricalRecords.user_model args).
The text was updated successfully, but these errors were encountered:
Describe the bug
The
SimpleHistoryAdmin.history_view
assumes that the user model associated with thehistory_user
is the one specified in AUTH_USER_MODEL, disregarding any class provided in theHistoricalRecords.user_model
argument.To Reproduce
[Taking the example from the docs: https://django-simple-history.readthedocs.io/en/latest/user_tracking.html#change-user-model]
models.py
admin.py
http://<HOSTNAME>/admin/<APP>/poll/<PK>/history/
(retrieve fromreverse(f"admin:{obj._meta.app_label}_{obj._meta.model_name}_history", args=[quote(obj.pk)])
).Expected behavior
Using the PollUser admin change URL (using the class provided in the
HistoricalRecords.user_model
args).The text was updated successfully, but these errors were encountered: