Is it better to use path() or url() in urls.py for django 2.0?

后端 未结 6 1691
小蘑菇
小蘑菇 2020-11-28 02:24

In a django online course, the instructor has us use the url() function to call views and utilize regular expressions in the urlpatterns list. I\'ve seen other

6条回答
  •  一生所求
    2020-11-28 02:58

    Regular expressions don't seem to work with the path() function with the following arguments: path(r'^$', views.index, name="index").

    It should be like this: path('', views.index, name="index").

    The 1st argument must be blank to enter a regular expression.

提交回复
热议问题