-
Notifications
You must be signed in to change notification settings - Fork 145
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
update urls.py - RemovedInDjango110Warning #116
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,29 @@ | ||
from django import __version__ as django_version | ||
try: | ||
from django.conf.urls import patterns, include, url | ||
except ImportError: | ||
from django.conf.urls.defaults import patterns, include, url | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not working in Django 1.10: first import |
||
|
||
from .views import SwaggerView, ResourcesView, SchemaView | ||
|
||
urlpatterns = patterns('', | ||
url(r'^$', SwaggerView.as_view(), name='index'), | ||
url(r'^resources/$', ResourcesView.as_view(), name='resources'), | ||
url(r'^schema/(?P<resource>\S+)$', SchemaView.as_view()), | ||
url(r'^schema/$', SchemaView.as_view(), name='schema'), | ||
) | ||
django_version = django_version.split('.') | ||
main_ver = int(django_version)[0] | ||
secondary_ver = int(django_version)[1] | ||
|
||
if main_ver == 1 and secondary_ver < 9: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something something use
|
||
urlpatterns = patterns('', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something something DRY. Declare |
||
url(r'^$', SwaggerView.as_view(), name='index'), | ||
url(r'^resources/$', ResourcesView.as_view(), name='resources'), | ||
url(r'^schema/(?P<resource>\S+)$', SchemaView.as_view()), | ||
url(r'^schema/$', SchemaView.as_view(), name='schema'), | ||
) | ||
else: | ||
# RemovedInDjango110Warning: | ||
# django.conf.urls.patterns() is deprecated and will be removed in Django 1.10. | ||
# Update your urlpatterns to be a list of django.conf.urls.url() instances instead. | ||
urlpatterns = [ | ||
url(r'^$', SwaggerView.as_view(), name='index'), | ||
url(r'^resources/$', ResourcesView.as_view(), name='resources'), | ||
url(r'^schema/(?P<resource>\S+)$', SchemaView.as_view()), | ||
url(r'^schema/$', SchemaView.as_view(), name='schema') | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably cleaner to call
get_version