user6541331
user6541331

Reputation:

Django Url unknown space

My urls.py is

   urlpatterns = [
         url(r'^admin/', admin.site.urls),
         url(r'^chat/', include('chat.urls'))
  ]

And My chat/urls.py is

   urlpatterns = [
          #url(r'^$', views.index, name="index"),
          url(r'input/$', views.input , name='input'),

        ]

Now when I try to hit the link http://127.0.0.1:8000/chat/input/ i got the error page not found 404.

It seems like there is an unknown space are after chat/ input. The Question why these spaces are there and how to remove them Screen shot of error message is here

View Code in as following

  def input(request):
       input = request.POST.get('msg', None)
      data ={
           'output': 'hi',
       }
     return JsonResponse(data)

Upvotes: 2

Views: 403

Answers (1)

Exprator
Exprator

Reputation: 27513

add the caret ^ sign before the url start or else it wont work

url(r'^input/$', views.input , name='input'),

or else

change this line

url(r'^chat/', include('chat.urls'))

to

url(r'^chat/$', include('chat.urls'))

Upvotes: 3

Related Questions