I understand you want to do this in Django. Well, if in your case you want to register and after the registration display the message, my tip would be this:
And at the end of your view registration function you should add a render request, like this:
def nome_da_sua_view(request):
# Código de cadastro aqui
return render(request, 'thanks.html', {})
Remember that it should stay within the validation if it is a POST method, something like this:
if request.method == 'POST':
Then you should add this redirect to your URLS:
urlpatterns = [
url(r'^thanks/', 'nome_do_seu_app.views.nome_da_sua_view'),
]
Finally, inside your template folder, it should contain an HTML file called Thanks.html.
You have two alternatives, make appear the message using
JavaScript
or link to redirect to another template that has this message, which is the question?– Paulo
Do you mean to implement a button using Javascript? Sorry ignorance is that I have never studied JS. My other question is whether there is any way I can create a button using HTML in conjunction with Django’s template tags that triggers a method I implemented myself?
– Douglas Cândido
What do you mean? This kind of thing can only be done via
Ajax
. If what you want is just to show a message, or you redirect to another page or write this message viaJavaScript
.– Paulo
It’s just that my teacher asked me to research how to implement my own methods to be used in Django and display their operation on a screen. That’s why I wanted to use the button to call a custom action.
– Douglas Cândido
For this you only have these options I mentioned, with
Ajax
you make a request to the server, process the request and return what you need without updating the page. The other way is to create a url that when accessing treats what you want and redirects to the successful page. This is at your discretion.– Paulo