在django项目中无法使用反向URL

时间:2014-08-17 04:09:22

标签: python django reverse

我已经构建了一个django项目,文件夹就是这样的

project_dir
  django_dir
    settings.py
    urls.py
  app_dir
    urls.py
    tables.py
    views.py

在tables.py中我添加了:

from django.core.urlresolvers import reverse

print reverse('caseUpdate',args=[1])

系统提出: 包含的urlconf django_dir.urls中没有任何模式

但我在django shell中使用了反向,它可以工作!

我可以从哪里开始调试?


打印出我的urls.py

django_dir - > urls.py如下:

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

from django.contrib import admin

from django_dir import settings

from django.conf.urls.static import static

# xadmin, powerful and elegent admin system written by chinese
import xadmin


from xadmin.plugins import xversion
xversion.register_models()

admin.autodiscover()
xadmin.autodiscover()

urlpatterns = patterns('',
    # Examples:

    url(r'^static/(?P<path>.*?)$','django.views.static.serve',{
        'document_root':settings.STATIC_ROOT}),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^dispute/',include('dispute.urls')),
    url(r'xadmin/', include(xadmin.site.urls)),
)

app_dir - &gt; urls.py如下:

from django.conf.urls import patterns, include, url
from app_dir import views


urlpatterns = patterns('',
    url(r'^$',views.dashboard,name='dashboard'),
    url(r'^(?P<caseId>\d+)refund/',views.refund,name='refund'),
    url(r'^(?P<caseId>\d+)reply/',views.reply,name='reply'),
    url(r'^(?P<caseId>\d+)/update',views.caseUpdate,name='caseUpdate'),
    url(r'^(?P<caseId>\d+)/statuUpdate',views.statuUpdate,name='statuUpdate'),
    url(r'^(?P<caseId>\d+)/performanceUpdate',views.performanceUpdate,name='performanceUpdate'),
    url(r'^(?P<caseId>\d+)/',views.detail,name='detail'),
    url(r'^search/',views.dashboard,name='case_search'),
)

0 个答案:

没有答案