我有一个带有一个主页的应用程序,它有几个按钮。每个按钮执行一些视图功能,然后返回主页面。单击下面的按钮时,它将返回该主页,但网址为:http://localhost:8080/abc_app/backup_system。当我点击浏览器刷新按钮时,这会创建一些POST重发提示/问题。
我有没有回复http://localhost:8080/abc_app而不是http://localhost:8080/abc_app/backup_system?
提前致谢。
<form action="{% url 'abc_app:backup_system' %}" method="post">{% csrf_token %}
<button type="submit" name="index" class="btn btn-primary btn-block float-right"value="index">Refresh</button>
</form>
def backup_system(request):
status = g_abc_api.backup_system()
return index(request)
# I have tried HttpResponseRedirect('/compost') as well.
# If possible, it would be great to have the 'status' variable returned from the API available in index(request) so I can display errors.
def index(request):
'''
Populate context
''
return render(request, 'abc_app/index.html', context)
答案 0 :(得分:0)
您可以使用HttpResponseRedirect
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];
self.tabBarController = [[ALTabBarController alloc] init];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];