How to redirect in django through select option in forms.py

Asked
Active3 hr before
Viewed126 times

4 Answers

redirectselectformsdjango
90%

Example_snippet/controller/utility/_redirect.js/ LOGIN_REDIRECT_URL = 'home'. . .
LOGIN_REDIRECT_URL = 'home'
load more v
88%

Generic editing views (Django docs),If any data is invalid, re-display the form, this time with any user populated values and error messages for the problem fields,,Django Tutorial Part 6: Generic list and detail views,localize: Enables the localization of form data input (see link for more information)

Example_snippet/controller/utility/_redirect.js/ <form action="/team_name_url/". . .
<form action="/team_name_url/" method="post">
   <label for="team_name">Enter name: </label>
   <input id="team_name" type="text" name="name_field" value="Default name for team.">
   <input type="submit" value="OK">
</form>
load more v
72%

Django’s login form is returned using the POST method, in which the browser bundles up the form data, encodes it for transmission, sends it to the server, and then receives back its response,,In HTML, a form is a collection of elements inside <form>

Example_snippet/controller/utility/_redirect.js/ <form action="/your-name/" met. . .
<form action="/your-name/" method="post">
    <label for="your_name">Your name: </label>
    <input id="your_name" type="text" name="your_name" value="{{ current_name }}">
    <input type="submit" value="OK">
</form>
load more v
65%

Connect and share knowledge within a single location that is structured and easy to search,,Asking for help, clarification, or responding to other answers

Example_snippet/controller/utility/_select.js/ if request.method == "POST": . . .
if request.method == "POST":
   form = RegisterForm(request.POST)
if form.is_valid():
   form.save()
plan = form.cleaned_data['plan']
print(plan)
if plan == 'Option 1':
   return redirect("/main/login/")
else :
   return redirect("/main/checkout/")
else :
   form = RegisterForm()
return render(request, 'signup.html', {
   "form": form
})