我正在使用python和Django运行网站。我已经进行了运行所需的所有更改。

urls.py:

urlpatterns = [
url('index.html', views.index, name='index'),
url('admin/', admin.site.urls),
url('', views.user_login, name='user_login'),
url('dashboard', views.obs_index, name='admin_dash'),
url('halls/active', views.obs_halls_active, name='active-halls'),
url('halls/pending', views.obs_halls_pending, name='pending-halls')
]


obs_index.html:

{% block bookings %}
  <li>
    <a href="javaScript:void();" class="waves-effect">
      <i class="fa fa-calendar-o"></i>
      <span>Bookings</span> <i class="fa fa-angle-left pull-right"></i>
    </a>
    <ul class="sidebar-submenu">
        <li><a href="{% url 'obsadmin:bookings_user' %}"><i class="zmdi zmdi-star-outline"></i> By Users</a></li>
        <li><a href="{% url 'obsadmin:bookings_owner' %}"><i class="zmdi zmdi-star-outline"></i> By Owners</a></li>
    </ul>
  </li>
{% endblock %}


当我运行并单击预订菜单时,它不起作用。这是为什么?

最佳答案

from django.conf.urls import url
urlpatterns = [
        url(r'^index/$, views.index, name='index')]


您必须以这种方式或更新版本来更改网址格式

from django.urls import path
urlpatterns = [
    path('index/', views.index, name='index')]

关于python - 在Django中未返回任何内容的网址,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59817568/

10-15 17:51