2017-12-12 4 views
0

Django 프로젝트에 다음 urls.py 파일이 있는데 URL과 경로와 관련된 최신 구문과 관련된 오류가 발생합니다.Django URLs 파일 오류

나는 내 사이트 (바깥 쪽 디렉토리)에 url.py있는 URL을 파일에 가지고있는 코드는 다음과 같습니다

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


urlpatterns = [ 
    path(r'^$', include('aboutme.urls')), 

] 

오류 메시지는 다음과 같습니다

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'라고하는 실제 앱 (웹 사이트 폴더) 인 urls.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'), 

] 

누구나 올바른 구문이나 문제를 해결할 수 있습니까?

UPDATE :

나 또한 다시 가서 (이전 작업 버전에 있었다) 관리자 명령을 포함하는 주 내 사이트의 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. 
+1

업데이트 된 코드'R '는''에 공백이 있습니다. 빈 문자열'' ''을 사용해야합니다. – Alasdair

답변

2

urls.py 파일의 ^$를 제거합니다.

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

urlpatterns = [ 
    path(r'', include('aboutme.urls')), 
] 

그리고 당신의 응용 프로그램 urls.py

:

당신이 path()를 사용하는 경우들이 더 이상 필요하지 않은 장고 2.0
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'), 
] 

.

관련 링크 : https://code.djangoproject.com/ticket/28691

+0

나는 그것을 시도했지만 함께 올랐다 : mysite.urls에 정의 된 URLconf를 사용하여 Django는 다음 URL 패턴을 다음 순서로 시도했다. 빈 경로가 이들 중 하나와 일치하지 않는다. Django 설정 파일에 DEBUG = True가 있으므로이 오류가 표시됩니다. 이것을 False로 변경하면 Django는 표준 404 페이지를 표시합니다. – MissComputing

+0

그들은 더 이상 필요하지 않지만'path()'와 함께 사용하지 않는다. 'url()'은 여전히 ​​존재하고, 당신은 그것을 * 사용합니다. –

+0

그냥 시도했지만 불행히도 여전히 작동하지 않습니다. 앱의 이름을 지정해야합니까? (연결하려는 디렉토리) – MissComputing