My views.py file is processing input data. How do I pop up a results window? Views.py code:

from django.http import HttpResponseRedirect from django.shortcuts import render from .forms import FormSQL from . import MY_FILE err1 = "Ошибка - 1" err2 = "Ошибка - 2" def index(request): if request.method == 'POST': form = FormSQL(request.POST) if form.is_valid(): mySQLServer = form.cleaned_data['mySQLServer'] myDataBase = form.cleaned_data['myDataBase'] a = MY_FILE.FilingTheFieldsOfName(mySQLServer, myDataBase) if a == err1: # Вот тут во всплывающем окне вывести данные else: if a == err2: # Вот тут во всплывающем окне вывести данные else: # Вот тут во всплывающем окне вывести данные else: form = FormSQL() return render(request, 'html/index.html', {'form': form}) 

HTML code, if necessary:

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Some</title> <link rel="icon" href="data:;base64,="> <link rel="stylesheet" type="text/css" href="C:\Bootstrap\css\bootstrap.css"> </head> <body> <div class="conteiner"> <div class="row"> <div class="col-md-12 text center"> <form action="" method="post"> {% csrf_token %} {{ form }} <input type="submit" value="Submit" /> </form> </div> </div> </div> </body> </html> 
  • The path of a web developer must begin with the understanding that a site is not really a single application, but two - a backend and a frontend written in different languages, running on different computers, in different environments and at different times. You cannot call a window from the front at the front. You can only return a response from it containing either a page layout or a redirect to another page. - Sergey Gornostaev
  • So for each condition I need to add my html file in which and display the values? @SergeyGornostaev - Pashok 3:04
  • Either so, or to make one template, but with a more complex rendering logic. - Sergey Gornostaev
  • Is it possible to do it via return HttpResponseRedirect ("<center> <p>" + err1 + "</ p> </ center>") ? It will certainly not very much, but in the same window. @SergeyGornostaev - Pashok 3:12

0