Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. def Insert(request):
  2.     if request.method == 'POST':    
  3.         form = insertForm(request.POST, prefix='insert')
  4.         print(request.POST)
  5.         print(form)
  6.         if form.is_valid():
  7.             person = form.cleaned_data['person']
  8.             location = form.cleaned_data['location']
  9.             name = form.cleaned_data['name']
  10.             sighted = form.cleaned_data['sighted']
  11.             connection.cursor().execute("INSERT INTO GUI_sightings(person, location, name_id, sighted) VALUES( %s,  %s, %s,  %s)", (person, location, name, sighted))
  12.             return HttpResponseRedirect('/')
  13.         else:
  14.             return render(request, 'GUI/insert.html', {'form': form})    
  15.     else:
  16.         form = insertForm()
  17.         return render(request, 'GUI/insert.html', {'form': form})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement