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

Support for missing URL names in Django 1.8 and 1.9 #89

Closed
florisdenhengst opened this issue Dec 29, 2015 · 0 comments
Closed

Support for missing URL names in Django 1.8 and 1.9 #89

florisdenhengst opened this issue Dec 29, 2015 · 0 comments

Comments

@florisdenhengst
Copy link
Contributor

URL names are optional in Django, but the silk.model_factory.construct_request_model method depends on the presence url_name in the resolved url.
This attribute is only set when a url_name is specified in the pattern for the requested url in Django >= 1.8.
If it is not set, the following error appears:

Traceback (most recent call last):
  File "[/path/to/django]/core/handlers/base.py", line 123, in get_response
    response = middleware_method(request)
  File "[/path/to/silk]/middleware.py", line 95, in process_request
    request_model = RequestModelFactory(request).construct_request_model()
  File "[/path/to/silk]/model_factory.py", line 166, in construct_request_model
    view_name = namespace + ':' + view_name
TypeError: Can't convert 'NoneType' object to str implicitly

The url_name is set by Django in versions 1.6 and 1.7 but not in 1.8 and 1.9.
In these latter two versions, a view_name is set instead.

It would be possible to use this view_name in construct_request_model whenever present (for Django>=1.8) or determine it as is currently done (for 1.6 >= Django > 1.8)

florisdenhengst added a commit to florisdenhengst/silk that referenced this issue Dec 29, 2015
Resolves jazzband#89 by using Django's url_name when it is present.
A fallback is included for Django 1.6-1.7.
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

1 participant