Django模板不会弹出或打开我的日期时间字段

时间:2017-11-09 09:36:48

标签: javascript python html django

我在使用django for loop模板时遇到了一个奇怪的错误,每当我使用我的" {%for groups in groups%}"对于循环,我的日期时间字段不会打开,但是当我尝试将其他上下文用于我的循环时,它只是起作用。我也只是简单地从我的其他html页面复制粘贴这个模态,因为它具有相同的功能。已检查是否与id和其他循环有任何冲突。还尝试检查模态按钮上的元素,并显示正确的组ID。我一直在这个html页面中为其他函数使用相同的循环,它似乎也正常工作。有关如何调试此问题的任何想法吗?

admin.html

{% for groups in groups %}
<!--start ALLOCATE MODAL -->
<div id="allocateModal-{{groups.id}}" class="modal fade" role="dialog" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="form-horizontal form-label-left">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
          </button>
          <h3 class="modal-title" id="myModalLabel">Allocate Device</h3>
        </div>
        <div class="modal-body">
          <h2>Device List</h2>
          <table class="table-width table table-striped jambo_table">
            <thead>
              <tr>
                <th style="width: 10%"></th>
                <th style="width: 30%">Device</th>
                <th>Quantity</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td class="a-center ">
                  <input type="checkbox" id="routerBox" onchange="enableRQty(this)">
                </td>
                <td>Router</td>
                <td>
                  <div class="col-md-4">
                    <input type="text" id="routerQty" class="form-control" data-inputmask="'mask': '9'" placeholder="0" disabled>
                  </div>
                </td>
              </tr>
              <tr>
                <td class="a-center ">
                  <input type="checkbox" id="switchBox" value="sw" onchange="enableSWQty(this)">
                </td>
                <td>Switch</td>
                <td>
                  <div class="col-md-4">
                    <input type="text" id="switchQty" placeholder="0" disabled class="form-control" data-inputmask="'mask': '9'">
                  </div>
                </td>
              </tr>

              <tr>
                <td class="a-center ">
                  <input type="checkbox" id="terminalBox" value="host" onclick="enableTQty(this)">
                </td>
                <td>Terminal</td>
                <td>
                  <div class="col-md-4">
                    <input type="text" id="terminalQty" placeholder="0" disabled class="form-control" data-inputmask="'mask': '9'">
                  </div>
                </td>
              </tr>
            </tbody>
          </table>
          <div class="form-group">
            <div class="col-md-6 col-sm-6 col-xs-12" style="padding-right: 0">
              <label class="control-label col-md-3" style="width: 17%" for="datetimepicker6">Date</label>
              <div class='input-group date' id='datetimepicker6'>
                <span class="input-group-addon">
                  <span class="fa fa-calendar-o"></span>
                </span>
                <input type='text' class="form-control" />
                <!-- <span class="input-group-addon">to</span> -->
              </div>
            </div>   

            <div class="col-md-6 col-sm-6 col-xs-12" style="padding-left: 0">
              <label class="control-label col-md-3" style="width: 12%" for="datetimepicker7">to</label>
              <div class='input-group date' id='datetimepicker7'>
                <input type='text' class="form-control" />
                <span class="input-group-addon">
                  <span class="fa fa-calendar-o"></span>
                </span>
              </div>
            </div>
          </div>
        </div>              
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          <button type="submit" class="btn btn-primary">Allocate</button>
        </div>
      </div>
    </div>
  </div>
</div>
<!-- end ALLOCATE MODAL -->
{% endfor %}

views.py

def adminPage(request):
currentUser = request.user

if currentUser.profile.usertype != 'admin':
    return HttpResponseRedirect("/user/")

signupForm = SignUpForm()
newgroupForm = CreateGroupForm()

users = User.objects.all()  
groups = Group.objects.all()
grouptodevice = GroupToDevice.objects.all()
devices = Device.objects.all()

context = {
'groups':groups,
'users':users,
'current_user': currentUser,
'newgroupForm': newgroupForm,
'signupForm' : signupForm,
'grouptodevice' : grouptodevice,
'devices':devices,
}
return render(request, 'admin.html', context)

0 个答案:

没有答案