简体   繁体   中英

NoReverseMatch at / django 1.8 form

Im getting this error trying to load my index.html that has a form inside with a view call on the "action" tag.

NoReverseMatch at /
Reverse for 'create' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Request Method: GET
Request URL:    http://localhost:8000/
Django Version: 1.8.3
Exception Type: NoReverseMatch
Exception Value:    
Reverse for 'create' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

This is my urls.py

from django.conf.urls import url
from . import views

urlpatterns = [
    url(r'^$', views.index, name='index'),
    url(r'^create_project/$', views.create, name='create'),
]

This is my view.py :

from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse

def index(request):
   return render(request, 'menu/index.html')

def create(request):
   return render(request, 'menu/detail.html')

This is the index.html part that shows the action tag that raises the error:

<form class="nobottommargin" id="template-contactform" name="template-contactform" action="{% url 'create' %}" method="post">
                                {% csrf_token %}

                                    <div class="col_half">
                                        <label for="name">Project Name <small>*</small></label>
                                        <input type="text" id="name" name="name" value="{{ current_name }}" class="sm-form-control required" />
                                    </div>

I dont know what im doing wrong, hope you can help me!

我使用相同的Django版本对您的数据进行了测试,并且可以正常工作,请检查其中一个,因为它必须不存在且尚未导入。

The mistake was tha my urls have been included by another urls.py.

Thanks @Daniel Roseman

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM