Python Django URL文件错误

Python Django URL文件错误,python,django,url,web,Python,Django,Url,Web,我在一个Django项目中有下面的url.py文件,我得到一个错误,我假设它与URL和路径的最新语法有关 我在mysite(最外层目录)的url文件url.py中的代码是: 错误信息为: Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order: ^$ The empty path didn't match any of these. 在名为“aboutme”的实际应用程序(

我在一个Django项目中有下面的url.py文件,我得到一个错误,我假设它与URL和路径的最新语法有关

我在mysite(最外层目录)的url文件url.py中的代码是:

错误信息为:

Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
^$
The empty path didn't match any of these.
在名为“aboutme”的实际应用程序(网站文件夹)中,URL.py文件如下所示:

from django.urls import path
from django.conf.urls import url, include 
from .import views #this is the main thing we are going to be doing ....returning views!

urlpatterns = [

        path(r'^$', views.index,name='index'),

]
谁能解释一下正确的语法或者我做错了什么

更新:

我还返回并尝试更新mysite的主url.py文件,以包含管理命令(在以前的工作版本中)。代码和产生的错误也如下所示:

尝试了此代码:

from django.contrib import admin
from django.urls import path
from django.conf.urls import url, include 


urlpatterns = [
    path('admin/', admin.site.urls),
    path(r' ', include('aboutme.urls')),

]
错误

Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
admin/
The empty path didn't match any of these.

删除
url.py
文件中的
^
$

from django.urls import path
from django.conf.urls import url, include 

urlpatterns = [
    path(r'', include('aboutme.urls')),
]
在你的应用程序中
url.py

from django.urls import path
from django.conf.urls import url, include 
from .import views #this is the main thing we are going to be doing 

app_name="myappname"
urlpatterns = [
    path(r'', views.index,name='index'),
]
在django 2.0中,如果您使用的是
path()
,则不再需要它们


相关链接:

我试过了,但结果是:Django使用mysite.URL中定义的URLconf尝试了这些URL模式,顺序如下:空路径与这些模式都不匹配。您看到此错误是因为Django设置文件中的DEBUG=True。将其更改为False,Django将显示一个标准的404页面。这并不是说不再需要它们,而是它们不再与
path()
一起使用
url()
仍然存在,您可以将它们与之一起使用。只是尝试了一下,但不幸的是,它仍然不起作用。我需要指定应用程序的名称吗?(我试图连接的目录)在哪里?你能把它写进你的密码(答案)吗?好的。我还添加了一个链接,可能有助于您的更新代码
r'
中有一个空格。您应该使用空字符串
'
from django.urls import path
from django.conf.urls import url, include 
from .import views #this is the main thing we are going to be doing 

app_name="myappname"
urlpatterns = [
    path(r'', views.index,name='index'),
]