Django Admin: object history not working

812 views
Skip to first unread message

Ryan Kite

unread,
Jun 21, 2021, 7:47:37 PM6/21/21
to Django users
Hello,

The issue is when clicking the "History" button on an object from the Django admin site, it opens to the template but says "This object doesn't have a change history. It probably wasn't added via this admin site."

From reading the docs it appears that: history_view() already exists (which is what I want)

/// from the doc page: 
ModelAdmin.history_view(requestobject_idextra_context=None)[source]

     Django view for the page that shows the modification history for a given model instance.

///

We can see the change history when doing:

 python manage.shell

import django.contrib.admin.models import LogEntry
from django.contrib.contenttypes.models import ContentType
from app import MyModel 

 results = LogEntry.objects.filter(content_type=ContentType.objects.get_for_model(MyModel ))

print(vars(results[1])) 

.. shows the change details

Please tell me what I'm missing or need to add. 



Christian Ledermann

unread,
Jun 22, 2021, 8:50:10 AM6/22/21
to django...@googlegroups.com
I am not sure what you are asking about.
The history works out of the box, but only when you manipulate entries via the django admin.
When you change the model instance through your own views, you have to explicitly create the log entry.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f59bfb29-c5be-459b-a984-ff1492150f92n%40googlegroups.com.


--
Best Regards,

Christian Ledermann

Dublin, IE
Mobile : +353 (0) 899748838

https://www.linkedin.com/in/christianledermann
https://github.com/cleder/


<*)))>{

If you save the living environment, the biodiversity that we have left,
you will also automatically save the physical environment, too. But If
you only save the physical environment, you will ultimately lose both.

1) Don’t drive species to extinction

2) Don’t destroy a habitat that species rely on.

3) Don’t change the climate in ways that will result in the above.

}<(((*>

Ryan Kite

unread,
Jun 22, 2021, 1:58:16 PM6/22/21
to Django users

Thanks for the clarification, I didn't realize it only applied to changes administered directly from the Django Admin. 
Was interested in learning about an objects' change history, but in this case, the changes were not performed from the Django Admin. 

Christian Ledermann

unread,
Jun 23, 2021, 4:42:41 AM6/23/21
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages