单选按钮重定向网址不起作用

时间:2018-07-03 17:39:51

标签: python html django url

我有两个注册页面,即学生视图和父视图。默认的注册URL在学生页面http://127.0.0.1:8000/account/student-sign-up/上。但是,当按下父按钮时,页面将重定向到http://127.0.0.1:8000/account/student-sign-up/parent_sign_up.html上的未知URL。我想知道如何使按钮重定向到http://127.0.0.1:8000/account/parent-sign-up,而没有学生注册前缀。

HTML

<!-- Radio check 1 -->
<div class="form-check form-check-inline radio">
    <label class="form-check-label">
        <input class="form-check-input" type="radio" name="radios" id="radio1" onclick="document.location.href='student_sign_up.html'"
            checked /> Individual
    </label>
</div>

<!-- Radio check 2 -->
<div class="form-check form-check-inline radio">
    <label class="form-check-label">
        <input class="form-check-input" type="radio" name="radios" id="radio2" onclick="document.location.href='parent_sign_up.html'"
        /> Parent of a child under 13
    </label>
</div>

urls.py

urlpatterns = [
    path('login/', views.login_view, name='login'),
    path('student-sign-up/', views.student_sign_up, name='student_sign_up'),
    path('parent-sign-up/', views.parent_sign_up, name='parent_sign_up'),
    path('teacher-sign-up/', views.teacher_sign_up, name='teacher_sign_up'),
    path('reset-password/', views.reset_password, name='reset_password'),
    path('reset-password-after/', views.reset_password2, name='reset_password_after'),

1 个答案:

答案 0 :(得分:1)

如下更改两个输入:

 <input class="form-check-input" type="radio" name="radios" id="radio1" onclick="document.location.href='/account/student-sign-up/'"
            checked /> Individual


 <input class="form-check-input" type="radio" name="radios" id="radio2" onclick="document.location.href='/account/parent-sign-up/'"
        /> Parent of a child under 13