Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
436 views
in Technique[技术] by (71.8m points)

How can i redirect to next url via POST method with Django generic.CreateView?

Pseudocode:
1.User Signup via following class-based view.
2.If signup success,then auto login and redirect to next url(enrollment) via GET method.

My problem is here. how can i redirect to next url(enrollment) via POST method?

class StudentRegisterView(generic.CreateView):
form_class = StudentRegisterForm
template_name = 'attendance_system/register.html'
success_url = reverse_lazy("enrollment")

    def form_valid(self,form):
        valid = super(StudentRegisterView,self).form_valid(form)
        username = form.cleaned_data.get('username')
        password = form.cleaned_data.get('password1')
        user = authenticate(username=username,password=password)
        login(self.request,user)
        return valid
question from:https://stackoverflow.com/questions/65889330/how-can-i-redirect-to-next-url-via-post-method-with-django-generic-createview

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...