小编Lol*_*rla的帖子

Django:HTML表单操作指向使用2个参数查看(或url?)

大约一周前开始学习django并碰壁.真的很感激任何启蒙......

models.py

class data(models.Model):
    course = models.CharField(max_length = 250)

    def __str__(self):
        return self.course
Run Code Online (Sandbox Code Playgroud)

HTML

将models.course中的对象转换为schlist

<link rel="stylesheet" type="text/css" href="{% static '/chosen/chosen.css' %}" />
<form action={% views.process %}  method="GET">
      <div>
        <h4 style="font-family:verdana;">First Course: </h4>
        <select data-placeholder="Course" style="width:350px;" class="chosen-select" tabindex="7">
          <option value=""></option>
          {% for item in schlist %}
          <option> {{ item }} </option>
          {% endfor %}
        </select>
      </div>
      </br>
      <div>
        <h4 style="font-family:verdana;">Second Course:</h4>
        <select data-placeholder="Course" style="width:350px;" class="chosen-select" tabindex="7">
          <option value=""></option>
          {% for item in schlist %}
          <option> {{ item }} </option>
          {% …
Run Code Online (Sandbox Code Playgroud)

html django django-urls django-forms django-views

5
推荐指数
2
解决办法
2万
查看次数

标签 统计

django ×1

django-forms ×1

django-urls ×1

django-views ×1

html ×1