Django - Bootstrap下拉列表不起作用

时间:2018-01-06 13:38:51

标签: python html django twitter-bootstrap python-3.x

我正在使用我的Django Web应用程序,我似乎无法让点击列表在点击时实际下拉。

        <div class="panel panel-default">
      <div class="panel-body">
         <div class="dropdown">
      <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Actions
      <span class="caret"></span></button>
      <ul class="dropdown-menu">
        <li><a href="{% url 'start' uuid=uuid %}">Start</a></li>
        <li><a href="{% url 'clone' uuid=uuid %}">Clone</a></li>
        <li><a href="{% url 'stop' uuid=uuid %}">Stop</a></li>
        <li><a href="{% url 'paranoidfish' uuid=uuid %}">Run Anti-Anti-Forensics Checker</a></li>

      </ul>
    </div>

并通过请求我的urls.py,虽然我不完全确定这是如何相关的

  urlpatterns = [
        #multiurl(
        url(r'^$', views.index, name='index'),
        #url(r'^$', views.transfer, name='transfer'),
        url(r'^malware/$', views.malware, name='malware'), # Add this /malware/ route
        url(r'^pokedex/$', views.pokedex, name='pokedex'),  # Add this /malware/ route

        url(r'^about/$', views.about, name='about'), # Add this /about/ route
        #url(r'^(?P\d+)/results/$', views.results, name='results'),
      #  url(r'^(?P<>\d+)/Clone/$', )
        url(r'^clone/(?P<uuid>[\w\-]+)$', views.clone, name='clone'),

        url(r'^start/(?P<uuid>[\w\-]+)$', views.start, name='start'),
        url(r'^paranoidfish/(?P<uuid>[\w\-]+)$', views.paranoidfish, name='paranoidfish'),
        url(r'^stop/(?P<uuid>[\w\-]+)$', views.stop, name='stop'),
        url(r'^transfer/(?P<uuid>[\w\-]+)$', views.transfer, name='transfer'),
     #   url(r'^(?P<uuid>[\w\-]+)/(?P<malware>[\w\-]+)$', views.execute, name='execute'),

        url(r'^execute/(?P<uuid>([0-9\-a-f]+))/(?P<malware>[-A-Z\0-9\-a-z]+)/$', views.execute, name='execute'),
        url(r'^transfer/(?P<uuid>([0-9\-a-f]+))/(?P<malware>[-A-Z\0-9\-a-z]+)/$', views.transfer, name='transfer'),
    #)
              ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

1 个答案:

答案 0 :(得分:2)

您的模板似乎正确无误。如果您的下拉菜单没有显示,您可能错过了导入Bootstrap JS库和/或jQuery。

Bootstrap v3

<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

Bootstrap v4

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>