那么其他的app中的urls.py中就不需要写app_name='应用名'了,看app01下urls.py的写法:
from django.conf.urls import url from django.contrib import admin from app01 import views urlpatterns = [ # url(r'^admin/', admin.site.urls), url(r'^index/', views.index,name='index'), ]app02下urls.py的写法:
from django.conf.urls import url from django.contrib import admin from app02 import views urlpatterns = [ # url(r'^admin/', admin.site.urls), url(r'^index/', views.index,name='index'), ]视图的写法:
#app01 def index(request): print(reverse('app01:index')) return HttpResponse('ok') #app02 def index(request): print(reverse('app02:index')) return HttpResponse('ok2')