我正在构建一个简单的管理面板,希望每次用户登录时都显示SweetAlert2弹出窗口。
成功登录后,我的用户将重定向到index.php,我希望当用户加载到index.php中时,将显示弹出窗口。
我该怎么做? :)
答案 0 :(得分:0)
在您的页面上使用此代码
class register_new(SessionWizardView):
template_name = "register/register.html"
form_list = [RegisterForm1, RegisterForm2]
def done(self, form_list, form_dict, **kwargs):
form1 = RegisterForm1(self.request.POST)
form2 = RegisterForm2(self.request.POST)
if form1.is_valid() and form2.is_valid():
username = self.request.POST['username']
email = self.request.POST['email']
password = self.request.POST['password1']
int_field = self.request.POST['int_field']
char_field = self.request.POST['char_field']
user = Account(username=username, email=email, password=password, int_field=int_field, char_field=char_field)
user.save()
ModelA.objects.create(user=user, classification="c")
ModelA.objects.create(user=user, classification="h")
ModelA.objects.create(user=user, classification="f")
ModelA.objects.create(user=user, classification="e")
return redirect('/')