2014-10-07 82 views
2

我尝试同步2个Django的项目,并正与以下错误发现自己:Django的 - NoReverseMatch在

Reverse for 'file-add' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

有现在似乎是一个问题与模板,第15行:

5 
6 
7 {% block content %} 
8 
9 {% if form.non_field_errors %} 
10 <div class="panel"> 
11 {{ form.non_field_errors }} 
12 </div> 
13 {% endif %} 
14 
15 <form action="{% url 'file-add' %}" method="post" enctype="multipart/form-data"> 
16 <fieldset> 
17  <legend>Add CV</legend> 
18 
19  <div class="large-12 columns"> 
20  <div class="row" id="file_container"> 
21   {% if form.f.errors %} 
22   <input placeholder="First name" name="f" type="file" id="file" class="error" /> 
23   {% else %} 
24   <label for="f" name="CV" /> 
25   <input name="f" type="file" id="file" /> 

由于我不记得以任何方式更改此模板,并且所有文件应该与我的其他服务器上的文件相同,是否有任何小问题,然后我失踪?

> <form action="{% url 'file-add' %}" method="post" enctype="multipart/form-data"> 

编辑

这似乎是与我的网址文件。我有一个主要的URL文件,它将URL“/ jobs /”转发给作业url文件。

url(r'^jobs/', include('jobs.urls', namespace="jobs")), 
url(r'^admin/', include(admin.site.urls)), 
url(r'^admin_tools/', include('admin_tools.urls')), 

作业url文件然后指向相关的作业页面。

url(r'^new', views.importDemoData, name='importDemoData'), 
url(r'^add', FileAddView.as_view(), name='file-add'), 
url(r'^files/list', FileListView.as_view(), name='list'), 

# This view lists uploaded files 
url(r'^success', FileListView.as_view(), name='home'), 
url(r'^(?P<unique_id>\w+)/$', views.application, name='application'), 

如果我移动“文件添加”行到主文件的URL,它似乎工作...

回答

0

你忘了URL名称前添加命名空间

“jobs/add”的反转将{%url'作业:file-add'%}这是{%url'namespace:name'%}。

当你删除它的工作,因为命名空间中的“工作/添加”链接将匹配{%URL“文件添加”%}

0

如果有人可以解释这对我来说这将是伟大的..

我删除了命名空间,从该行的主要的URL文件:

url(r'^jobs/', include('jobs.urls', namespace="jobs")), 

将其更改为:

url(r'^jobs/', include('jobs.urls')), 

它的工作!这一点都不奇怪,因为它似乎是工作的罚款就像我的其他服务器上..

0

正如他们自己的文件中说:url-namespaces-and-included-urlconfs

URL namespaces of included URLconfs can be specified in two ways.

Firstly, you can provide the application and instance namespaces as arguments to include() when you construct your URL patterns. For example,:

url(r'^polls/', include('polls.urls', namespace='author-polls', app_name='polls')),

This will include the URLs defined in polls.urls into the application namespace 'polls', with the instance namespace 'author-polls'.

Secondly, you can include an object that contains embedded namespace data. If you include() a list of url() instances, the URLs contained in that object will be added to the global namespace. However, you can also include() a 3-tuple containing:

(<list of url() instances>, <application namespace>, <instance namespace>)

1

我想你应该添加URL名称的命名前面