I want my url to accept 0 or more digits(positive or negative integers), I mean it should match '/','/0',...,'/9' as well as '/-9','/-88' etc.
This is the regex I am using ^([-]?[0-9]*)/$ . It works for all urls except '/', what is the problem with this regex?
EDIT:
This is my urlpatterns in urls.py in project directory:
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'',include('basecalendar.urls'), name='date'),
]
and this is urlpattern for basecalendar
urlpatterns=[
url(r'^([-]?[0-9]*)/$',views.get_date),
]
Since you are working with urls you might want to make sure that you are ending your url with '/'. Also, the reason why this is not working because your url is expecting a '/' at the end. So a url something/ does not match your regex, rather something// does. All these observations are being made according to your regex. Usually to handle such conditions you should add one more url above your previous regex, something like:
url(r'^something/$', view),
url(r'^something/([-]?[0-9]*)/$', view),