I’m doing registration on Django. I made a form, added a button that should refresh the page and send a POST request. But the button does not update the page and does not send the request. I doesn’t have any scripts on JavaScript.
My views.py code:
`from django.shortcuts import render, redirect
from .models import User
from .forms import UserForm
from django.views import View
def index(request):
return render(request, ‘index.html’)
def inn(request):
return render(request, ‘in.html’)
class PostCreate(View):
def up(self, request):
form=UserForm(request.POST)
if form.is_valid():
form.save()
return redirect(‘home’)
def down(request):
return render(request, 'up.html')`
My forms.py code:
`from .models import User
from django.forms import ModelForm
class UserForm(ModelForm):
class Meta:
model=User
fields=[‘NickName’, ‘Email’, ‘Password’]`
And HTML:
enter image description here
I’m tried to search any information on internet, but I’m found only about event.preventDefault() and type=’button’. But I doesn’t have any scripts and my type is ‘submit’
Hopen_Pen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.