Friday, April 28, 2017

Re: NoReverseMatch

Hey,


Traceback:

======================================================================

ERROR: test_event_view (cal.tests.EventsTestCase)

----------------------------------------------------------------------

Traceback (most recent call last):

  File "/Users/williamholmes/organiser/organiser/cal/tests.py", line 79, in test_event_view

    response = self.client.get('/cal/events/1/')

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/test/client.py", line 529, in get

    **extra)

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/test/client.py", line 333, in get

    return self.generic('GET', path, secure=secure, **r)

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/test/client.py", line 409, in generic

    return self.request(**r)

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/test/client.py", line 494, in request

    six.reraise(*exc_info)

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/utils/six.py", line 686, in reraise

    raise value

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/core/handlers/exception.py", line 42, in inner

    response = get_response(request)

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/core/handlers/base.py", line 187, in _get_response

    response = self.process_exception_by_middleware(e, request)

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/core/handlers/base.py", line 185, in _get_response

    response = wrapped_callback(request, *callback_args, **callback_kwargs)

  File "/Users/williamholmes/organiser/organiser/cal/views.py", line 61, in viewevent

    return render(request, 'view_event.html', {'form':form})

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/shortcuts.py", line 30, in render

    content = loader.render_to_string(template_name, context, request, using=using)

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/template/loader.py", line 68, in render_to_string

    return template.render(context, request)

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/template/backends/django.py", line 66, in render

    return self.template.render(context)

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/template/base.py", line 208, in render

    return self._render(context)

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/test/utils.py", line 94, in instrumented_test_render

    return self.nodelist.render(context)

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/template/base.py", line 994, in render

    bit = node.render_annotated(context)

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated

    return self.render(context)

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/template/loader_tags.py", line 174, in render

    return compiled_parent._render(context)

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/test/utils.py", line 94, in instrumented_test_render

    return self.nodelist.render(context)

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/template/base.py", line 994, in render

    bit = node.render_annotated(context)

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated

    return self.render(context)

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/template/defaulttags.py", line 439, in render

    url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/urls/base.py", line 91, in reverse

    return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))

  File "/Users/williamholmes/.virtualenvs/organiser/lib/python3.5/site-packages/django/urls/resolvers.py", line 392, in _reverse_with_prefix

    (lookup_view_s, args, kwargs, len(patterns), patterns)

django.urls.exceptions.NoReverseMatch: Reverse for 'delete_event' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['cal/events/(\\d+)/delete_event$']


cal:urls:

from django.conf.urls import url, include
from django.contrib import admin
from cal import views, models

app_name = 'cal'
urlpatterns = [
    url(r'^$', views.home, name='home'),
    url(r'^newevent/$', views.newevent, name='newevent'),
    url(r'^events/(\d+)/', views.viewevent, name='viewevent'),
    url(r'^(?P<month>\d+)/(?P<year>\d+)$', views.home, name='another-month'),
    url(r'^events/(\d+)/delete_event$', views.delete_event, name='delete_event'),
]


urls:

from django.conf.urls import url, include
from cal import urls as cal_urls
from accounts import urls as accounts_urls

urlpatterns = [
    url(r'^cal/', include(cal_urls, namespace="cal")),
    url(r'^accounts/', include(accounts_urls)),
]


Let me know if you need anything else. :)


Cheers,


Will


 Friday, April 28, 2017 at 10:01:33 PM UTC+1, James Schneider wrote:
Hey all,

Can anyone tell me the (probably quite obvious) reason my reverse match isn't working?

Post the traceback and urls.py files. You're referencing the 'cal' name space, so the single URL line you posted is not enough to make a determination.

-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/216445d5-247a-42ee-9689-000d4d1daaca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment