我在项目中使用CreateView进行注册,但我想阻止经过身份验证的用户访问注册网址,而是将其重定向到另一个页面。
谁能告诉我该怎么做? 这是我的注册查看代码:
class RegisterUserView(CreateView):
model = ChatUser
template_name = 'login/registration_page.html'
form_class = UserForm
second_form_class = ProfileForm
答案 0 :(得分:0)
您可以使用UserPassesTestMixin
:
try {
Process su = Runtime.getRuntime().exec("java -jar <jar file> <more command code>");
DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());
StringBuffer output = null;
BufferedReader reader=new BufferedReader(new
InputStreamReader(su.getInputStream()));
String line="";
while((line=reader.readLine())!=null){
output.append(line+"\n");
}
String response=output.toString();
AlertDialog.Builder dialog=new AlertDialog.Builder(this);
dialog.setMessage(response);
dialog.show();
outputStream.writeBytes("exit");
outputStream.flush();
}
catch (IOException e)
{
AlertDialog.Builder dialog=new AlertDialog.Builder(this);
dialog.setMessage(e+"");
dialog.show();
}