MCPcopy
hub / github.com/django/django / message_user

Method message_user

django/contrib/admin/options.py:1412–1438  ·  view source on GitHub ↗

Send a message to the user. The default implementation posts a message using the django.contrib.messages backend. Exposes almost the same API as messages.add_message(), but accepts the positional arguments in a different order to maintain backwards compatibi

(
        self, request, message, level=messages.INFO, extra_tags="", fail_silently=False
    )

Source from the content-addressed store, hash-verified

1410 return construct_change_message(form, formsets, add)
1411
1412 def message_user(
1413 self, request, message, level=messages.INFO, extra_tags="", fail_silently=False
1414 ):
1415 """
1416 Send a message to the user. The default implementation
1417 posts a message using the django.contrib.messages backend.
1418
1419 Exposes almost the same API as messages.add_message(), but accepts the
1420 positional arguments in a different order to maintain backwards
1421 compatibility. For convenience, it accepts the `level` argument as
1422 a string rather than the usual level number.
1423 """
1424 if not isinstance(level, int):
1425 # attempt to get the level if passed a string
1426 try:
1427 level = getattr(messages.constants, level.upper())
1428 except AttributeError:
1429 levels = messages.constants.DEFAULT_TAGS.values()
1430 levels_repr = ", ".join("`%s`" % level for level in levels)
1431 raise ValueError(
1432 "Bad message level string: `%s`. Possible values are: %s"
1433 % (level, levels_repr)
1434 )
1435
1436 messages.add_message(
1437 request, level, message, extra_tags=extra_tags, fail_silently=fail_silently
1438 )
1439
1440 def save_form(self, request, form, change):
1441 """

Callers 14

response_addMethod · 0.95
response_changeMethod · 0.95
response_actionMethod · 0.95
response_deleteMethod · 0.95
_save_formsetMethod · 0.95
changelist_viewMethod · 0.95
delete_selectedFunction · 0.80
message_debugMethod · 0.80
message_infoMethod · 0.80
message_successMethod · 0.80
message_warningMethod · 0.80

Calls 2

valuesMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected