1

I'm using Django v1.8

I installed django-simple-history and I registered my models.

However I can't register User or Group to django-simple-history.

When I'm trying

admin.site.register(User, SimpleHistoryAdmin)

I get the error:

 The model User is already registered
zinon
  • 4,427
  • 14
  • 70
  • 112
  • You might have problems using `SimpleHistoryAdmin` for the `User` model - it doesn't understand how to deal with the password field. – Alasdair May 26 '16 at 10:33
  • @Alasdair Can I use any history module for `User` and `Group`? – zinon May 26 '16 at 10:35
  • The simple history docs suggest you can register user if you use their `register` method. I haven't used django-simple-history before so I haven't tested to see whether it works. – Alasdair May 26 '16 at 10:47

1 Answers1

2

Usually, when you get the 'The model is already registered' error message, you need to unregister it first.

admin.site.unregister(User)
admin.site.register(User, SimpleHistoryAdmin)

However, in this case, the django-simple-history docs for using a third party mode suggest that you should use their register method instead of admin.site.register.

from simple_history import register
from django.contrib.auth.models import User

register(User)
Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • I tried it and even though in my sql workbench the data are stored I can't access it from `/admin` site. I see `NoReverseMatch at /admin/auth/user/3/history/ Reverse for 'app_list' with arguments '()' and keyword arguments '{u'app_label': ''}' not found. 1 pattern(s) tried: [u'admin/(?PeReg|auth)/$']` – zinon May 26 '16 at 10:57
  • I haven't used django-simple-history before, so I don't know whether it's a bug in your code or the app. – Alasdair May 26 '16 at 10:59
  • OK, thank you for your response! It works so it's fine for me. I'll try to fix is in `/admin/User` site. – zinon May 26 '16 at 11:01