Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
12660 Lượt xem

Hello,

I created a module on website (frontend). I do some stuff in my controller. When all is done correctly, I redirect the user to another page using "return http.request.redirect('/module/example')"

I would like to pass a parameter with this redirection. On the template of route "/module/example", I would like to display a success message on the top of the page if a have received a specific parameter.

How can I do this?

Thanks

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello,

Have you find answer for this? Please share..


Ảnh đại diện
Huỷ bỏ

You can store a key in session dict

request.session.update({'a':1})

return request.redirect('/ownership')

And then

@http.route('/ownership', auth='public',website=True)

if request.session.get('a')==1:

alert_check = True

else:

alert_check = False

request.session.update({'a':0})

You can use this check in template

<t t-if="alert_check">

<div class="row">

<div class="col-sm-3"></div>

<div class="col-sm-5">

<div class="alert alert-success alert-dismissible rounded-0 fade show d-print-none css_editable_mode_hidden">

<div class="container">

<p role="alert">

<h6 style="color:white">You have successfully save the data.</h6>

</p>

</div>

<button style="color:white" type="button" class="close" data-dismiss="alert" aria-label="Close"> × </button>

</div>

</div>

<div class="col-sm-3"></div>

</div>

</t>

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 7 24
3533
3
thg 4 24
3964
0
thg 9 21
1393
1
thg 3 15
4218
5
thg 9 24
15165