MCPcopy
hub / github.com/django/django / log_actions

Method log_actions

django/contrib/admin/models.py:27–54  ·  view source on GitHub ↗
(
        self, user_id, queryset, action_flag, change_message="", *, single_object=False
    )

Source from the content-addressed store, hash-verified

25 use_in_migrations = True
26
27 def log_actions(
28 self, user_id, queryset, action_flag, change_message="", *, single_object=False
29 ):
30 if isinstance(change_message, list):
31 change_message = json.dumps(change_message)
32
33 log_entry_list = [
34 self.model(
35 user_id=user_id,
36 content_type_id=ContentType.objects.get_for_model(
37 obj, for_concrete_model=False
38 ).id,
39 object_id=obj.pk,
40 object_repr=str(obj)[:200],
41 action_flag=action_flag,
42 change_message=change_message,
43 )
44 for obj in queryset
45 ]
46
47 if len(log_entry_list) == 1:
48 instance = log_entry_list[0]
49 instance.save()
50 if single_object:
51 return instance
52 return [instance]
53
54 return self.model.objects.bulk_create(log_entry_list)
55
56
57class LogEntry(models.Model):

Callers 11

log_additionMethod · 0.80
log_changeMethod · 0.80
log_deletionsMethod · 0.80
setUpTestDataMethod · 0.80
setUpMethod · 0.80
setUpTestDataMethod · 0.80
test_log_actionsMethod · 0.80
test_no_userMethod · 0.80

Calls 5

get_for_modelMethod · 0.80
bulk_createMethod · 0.80
dumpsMethod · 0.45
modelMethod · 0.45
saveMethod · 0.45

Tested by 8

setUpTestDataMethod · 0.64
setUpMethod · 0.64
setUpTestDataMethod · 0.64
test_log_actionsMethod · 0.64
test_no_userMethod · 0.64