Monday, June 21, 2021

Django Admin: object history not working

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. 



--
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+unsubscribe@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.

No comments:

Post a Comment