我有一個 FormView,在提交表單后我可以在其中做一些事情,然后我想重定向到條紋結帳。沒有Javascript有可能嗎?
class ApplicationForm(forms.ModelForm):
class Meta:
model = Application
fields = "email", "name"
def save(self, commit=True):
application = super().save(commit=commit)
checkout_session = stripe.checkout.Session.create(...) # I'm creating the session here and do some other stuff with the form input
return application
class ApplicationView(CreateView):
template_name = "application.html"
form_class = ApplicationForm
def get_success_url(self):
# TODO: How do I redirect to Stripe checkout here?
uj5u.com熱心網友回復:
您可以為此使用重定向:
from django.shortcuts import redirect
def get_success_url(self):
# Redirect the user to the Stripe Checkout page (i suppose that is an external url from your app)
stripe_checkout_url = 'https://stripe/checkout/url'
return redirect(stripe_checkout_url)
# If it's an app url like: stripe:checkout (name 'checkout' and namespace = 'stripe')
# return redirect('stripe:checkout')
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/347556.html
上一篇:在特定行上堆疊二維陣列
