How to pass information using an HTTP redirect (in Django)

后端 未结 11 871
北恋
北恋 2021-02-01 19:22

I have a view that accepts a form submission and updates a model.

After updating the model, I want to redirect to another page, and I want a message such as \"Field X su

11条回答
  •  有刺的猬
    2021-02-01 20:26

    This is a built-in feature of Django, called "messages"

    See http://docs.djangoproject.com/en/dev/topics/auth/#messages

    From the documentation:

    A message is associated with a User. There's no concept of expiration or timestamps.

    Messages are used by the Django admin after successful actions. For example, "The poll Foo was created successfully." is a message.

提交回复
热议问题