2๐
โ
I think django is interpreting (statics|analytics)
as a pattern for variable. I suggest as follow:
-
define 2 different url to the same view:
url(r'^v1/statistics/stats_bar$', views.stats_bar, name='stats_bar_statistics') url(r'^v1/analytics/stats_bar$', views.stats_bar, name='stats_bar_analytics') reverse('status_bar_statistics') # usage
and inside the view test which url has been used:
if 'analytics' in request.path: # do something elif 'statistics' in request.path: # do otherthing
-
you define one url with parameter:
url(r'^v1/ย (?P<type>(statistics|analytics))/stats_bar$', views.stats_bar, name='stats_bar') reverse('status_bar', kwargs={'type': 'statistics'}) # usage
๐คDhia
1๐
https://docs.djangoproject.com/en/stable/ref/urlresolvers/#reverse
Look at the section about args.
๐คmarkzz
Source:stackexchange.com