python - 单选按钮重定向 url 不起作用

标签 python html django url

我有两个注册页面:学生 View 和家长 View 。默认注册网址位于学生页面 http://127.0.0.1:8000/account/student-sign-up/ 。但是,当按下父按钮时,页面会重定向到未知 URL http://127.0.0.1:8000/account/student-sign-up/parent_sign_up.html。 。我想知道如何使按钮重定向到 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>

url.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'),

最佳答案

按如下方式更改两个输入:

 <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

关于python - 单选按钮重定向 url 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51160247/

相关文章:

python - makedirs错误: can GAE Python create new directories (folders) or not?

html - 一些具有不同内容的内联 block div 的垂直对齐

html - Angular HTML : ng-content in ngSwitch

jquery - Django View 中的 Mpld3 - "NoneType"对象没有属性 "split"

python - 如何解决 SuspiciousOperation : Invalid HTTP_HOST header error?

python - 有没有一种 Django 方法可以将测试结果与 fixture 进行比较?

python - cv2.createShapeContextDistanceExtractor 始终返回 0.0

python - 如何使用 3.x 模拟 2.x 的 lambda 参数元组解包?

python - 使用Python + BeautifulSoup提取网页表格中的文本

html - 如何在CSS中响应动态加载不同宽度和高度的图像