I'm trying to get all model operations in my django app with the following code but it returns an error. I get the error
NameError: name 'model_object' is not defined
def admin_main(request):
logs = LogEntry.objects.log_action(
user_id=request.user.id,
content_type_id=ContentType.objects.get_for_model(model_object).pk,
object_repr=unicode(obj),
object_id=obj.id,
message="",
action_flag=ADDITION if create else DELETION)
logs = logs.order_by('-action_time')[:40]
return render(request,'history.html', {"logs":logs})
try this
https://docs.djangoproject.com/en/4.0/ref/contrib/contenttypes/#the-contenttypemanager