Thursday, September 28, 2017

Re: django.urls.exceptions.NoReverseMatch: Reverse for 'index' not found. 'index' is not a valid view function or pattern name.



On Sep 27, 2017 8:59 PM, "harsh sharma" <harshsharma199622@gmail.com> wrote:
i m a noob in django And i dont know why i am getting this error

my views.py file:
from django.shortcuts import render,render_to_response
from django.http import HttpResponse
from all.models import ALL
from django.template import RequestContext
# Create your views here.
def home(request):
return render(request, 'index.html', {'ne': ne})


def technology(request):
return HttpResponse('<body>hello</body>')

def index(request):
assert isinstance(request , HttpResponse)
return render(request, 'index.html') . 

my url file
    url(r'^$', all.views.index),
url(r'^technology', all.views.index),
url(r'^index$', all.views.home),
url(r'^admin/', admin.site.urls),
]

None of the code you posted would have triggered such an error. 

What is contained in the template that is being rendered when the error is shown?

My guess is that you have something like {% url 'index' %} inside of your template, but you don't have any URL patterns named 'index' shown.

-James

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciW8Q_xLN_TWJ%3Ds4-ArQ-tfvcopZNJduFucfZ0xfXNaBNw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment