Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoReverseMatch: Reverse for 'summary' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: [] #74

Closed
a1Gupta opened this issue Aug 24, 2015 · 14 comments

Comments

@a1Gupta
Copy link

a1Gupta commented Aug 24, 2015

I am getting NoReverseMatch error. I tried placing middleware at top but its giving same error.

These are my middleware classes:

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'subdomains.middleware.SubdomainURLRoutingMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'social.apps.django_app.middleware.SocialAuthExceptionMiddleware',
    'django_mobile.middleware.MobileDetectionMiddleware',
    'django_mobile.middleware.SetFlavourMiddleware',
)

and its the traceback-

Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/home/ashish/.virtualenvs/myapp/local/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 64, in __call__
    return self.application(environ, start_response)
  File "/home/ashish/.virtualenvs/myapp/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 168, in __call__
    self.load_middleware()
  File "/home/ashish/.virtualenvs/myapp/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 44, in load_middleware
    mw_class = import_string(middleware_path)
  File "/home/ashish/.virtualenvs/myapp/local/lib/python2.7/site-packages/django/utils/module_loading.py", line 26, in import_string
    module = import_module(module_path)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/ashish/.virtualenvs/myapp/local/lib/python2.7/site-packages/silk/middleware.py", line 31, in <module>
    fpath = silky_reverse('summary')
  File "/home/ashish/.virtualenvs/myapp/local/lib/python2.7/site-packages/silk/middleware.py", line 27, in silky_reverse
    r = reverse(name, *args, **kwargs)
  File "/home/ashish/.virtualenvs/myapp/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 551, in reverse
    return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
  File "/home/ashish/.virtualenvs/myapp/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 468, in _reverse_with_prefix
    (lookup_view_s, args, kwargs, len(patterns), patterns))
NoReverseMatch: Reverse for 'summary' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
[24/Aug/2015 14:15:14] "GET /silk HTTP/1.1" 500 59

Is this error due to middleware placement or its some other issue ?

@mtford90
Copy link
Collaborator

mtford90 commented Sep 6, 2015

@a1Gupta apologies for the delay in getting to this - have you added silk to your url patterns?

@mtford90
Copy link
Collaborator

mtford90 commented Sep 6, 2015

Also - which django version?

@a1Gupta
Copy link
Author

a1Gupta commented Sep 6, 2015

@mtford90 yes I did and I am using Django 1.7.7

@zahlio
Copy link

zahlio commented Feb 25, 2016

We are also having this issue, using Django 1.8.

@ElSaico
Copy link

ElSaico commented Sep 8, 2016

I faced this as well; although the docs imply otherwise, seems like the app's endpoints are not optional. Just imported them into my urls.py and it worked again.

@avelis
Copy link
Collaborator

avelis commented Sep 8, 2016

@ElSaico Can you point to me where in the docs it says app's endpoints are optional? Maybe a result of this issue is to change the expectation for proper installation.

@matthewhegarty
Copy link

matthewhegarty commented Jun 21, 2017

Also seeing this on 1.11.1 - is there a fix or workaround?

I followed the install docs

  • django-silk-1.0.0
  • python 3.4.3

@avelis
Copy link
Collaborator

avelis commented Jun 21, 2017

@matthewhegarty What version of Django are you using? I wonder if the url patterns needs to be re-assessed with a configuration checker on config initialization.

@matthewhegarty
Copy link

matthewhegarty commented Jun 22, 2017

@avelis Django version 1.11.1

@mark-adams
Copy link

@avelis Looks like #86 resolves this issue.

@lmiguelvargasf
Copy link

I am getting the same issue when running tests with pytest:

  • django-silk 1.11.12
  • python 3.6.5

@tprestegard
Copy link

I had this issue with running unit tests in Django 1.11.14 and python 2.7.13. I found that it occurred because I have different settings files for production and test servers and only want the test servers to use silk. I also only wanted to add the silk urlpatterns on test servers, which I handled by implementing an if settings.DEBUG=True: statement in urls.py that contained the silk urlpatterns. I had done something similar for Django Debug Toolbar in the past.

However, it seems that running unit tests in Django sets settings.DEBUG=False automatically, overriding the global settings. So my configuration resulted in the silk urlpatterns not being added when unit tests were run, and caused this error to be generated.

My problem was solved by adding the --debug-mode flag when running unit tests, or alternatively, by checking for some requirement other than settings.DEBUG = True in urls.py, like 'silk' in settings.INSTALLED_APPS. However, I still suggest to merge the fix in #86 or do something similar. As far as I can tell, the fpath variable does not appear to be used anywhere else in this package, and along with this, doing a compile-time reverse does not seem like the best practice.

@xahin96
Copy link

xahin96 commented Dec 2, 2020

@tprestegard I am also facing the same issue! How do I run pytest in DEBUG MODE ?

@tprestegard
Copy link

@xahin96 I'm not sure whether that's possible. I ended up just doing the check like if 'silk' in settings.INSTALLED_APPS rather than if not settings.DEBUG since silk was only in settings.INSTALLED_APPS in my test settings.

I see that #86 was merged since my previous post, so I would think this is fixed in a more recent version of this package, but I can't say for certain from personal experience. If so, this issue could potentially be closed.

@auvipy auvipy closed this as completed Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests