setting.py
from django.contrib.messages import constants as message_constants
MESSAGE_TAGS = {message_constants.DEBUG: 'debug',
message_constants.INFO: 'info',
message_constants.SUCCESS: 'success',
message_constants.WARNING: 'warning',
message_constants.ERROR: 'danger',}
views.py
from django.contrib import messages
def Example(request):
if request.method == 'POST':
form = registerForm(request.POST)
if form.is_valid():
form.save()
> messages.success(request,'Register successfully !')
> messages.error(request,'Register successfully !')
> messages.info(request,'Register successfully !')
> messages.warning(request,'Register successfully !')
return redirect('/login')
else:
form = registerForm()
return render(request, 'app/register.html', {'form': form})
JUST USE MY STEP AS I DID ABOVE NO NEED TO EXECUTE AT HTML
Top comments (0)