See
https://stackoverflow.com/questions/987669/tying-in-to-django-admins-model-history
for a better explanation and alternatives

On Tue, 22 Jun 2021 at 18:59, Ryan Kite <ryanki...@gmail.com> wrote:

>
> 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.
>
>
> On Tuesday, June 22, 2021 at 5:50:10 AM UTC-7 christian...@gmail.com
> wrote:
>
>> 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.
>>
>> On Tue, 22 Jun 2021 at 00:48, Ryan Kite <ryan...@gmail.com> wrote:
>>
>>> 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(*request*, *object_id*, *extra_context=None*)
>>> [source]
>>> <https://docs.djangoproject.com/en/1.11/_modules/django/contrib/admin/options/#ModelAdmin.history_view>
>>> ¶
>>> <https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#django.contrib.admin.ModelAdmin.history_view>
>>>
>>>      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...@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
>>> <https://groups.google.com/d/msgid/django-users/f59bfb29-c5be-459b-a984-ff1492150f92n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>>
>> --
>> 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.
>>
>> }<(((*>
>>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cc8975e1-8b77-4316-92df-909eecaad98cn%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/cc8975e1-8b77-4316-92df-909eecaad98cn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
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.

}<(((*>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABCjzWq3UhJwtyz%2BQbAaAJg-ganZCr-JL%2BSXLdxrCYOruQ3pqQ%40mail.gmail.com.

Reply via email to