【问题标题】:Radio button redirect url not working单选按钮重定向网址不起作用
【发布时间】:2018-12-12 02:27:48
【问题描述】:

我有两个注册页面,学生视图和家长视图。默认注册网址在学生页面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'),

【问题讨论】:

    标签: python html django url


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-21
      • 2017-11-13
      相关资源
      最近更新 更多