Chatterbot: u'chatterbot' is not a registered namespace

Created on 16 Aug 2018  路  6Comments  路  Source: gunthercox/ChatterBot

I am running the Django app by executing python manage.py runserver localhost:8000
and receiving this error:

NoReverseMatch at /

u'chatterbot' is not a registered namespace

Request Method:     GET
Request URL:    http://localhost:8000/
Django Version:     1.11.15
Exception Type:     NoReverseMatch
Exception Value:    

u'chatterbot' is not a registered namespace

Exception Location:     /usr/lib64/python2.7/site-packages/django/urls/base.py in reverse, line 87
Python Executable:  /bin/python
Python Version:     2.7.5
Python Path:    

['/home/oracle/Git/ChatterBot/examples/django_app',
 '/usr/lib64/python27.zip',
 '/usr/lib64/python2.7',
 '/usr/lib64/python2.7/plat-linux2',
 '/usr/lib64/python2.7/lib-tk',
 '/usr/lib64/python2.7/lib-old',
 '/usr/lib64/python2.7/lib-dynload',
 '/usr/lib64/python2.7/site-packages',
 '/usr/lib64/python2.7/site-packages/gtk-2.0',
 '/usr/lib/python2.7/site-packages']

Server time:    Thu, 16 Aug 2018 10:57:51 +0000

Adding url(r'^chatterbot/', include('chatterbot.ext.django_chatterbot.urls', namespace='chatterbot'), to urls.py gives me this error:

Unhandled exception in thread started by <function wrapper at 0x7f490f5e5578>
Traceback (most recent call last):
...
  File "/home/oracle/Git/ChatterBot/examples/django_app/example_app/urls.py", line 11
    ]
    ^
SyntaxError: invalid syntax

Please help.

answered

Most helpful comment

I have solved problem by replacing var chatterbotUrl = '{% url "chatterbot" %}'; by var chatterbotUrl = '{% url "chatterbot:chatterbot" %}'; on line 46 in template/app.html

All 6 comments

I found the error. To make it work, I changed example_app/urls.py to:

from django.conf.urls import include, url
from django.contrib import admin
from chatterbot.ext.django_chatterbot import urls as chatterbot_urls
from example_app.views import ChatterBotAppView


urlpatterns = [
    url(r'^$', ChatterBotAppView.as_view(), name='main'),
    url(r'^admin/', include(admin.site.urls), name='admin'),
    url(r'^chatterbot/', include('chatterbot.ext.django_chatterbot.urls', namespace='chatterbot')),
]

and in example_app/templates/app.html changed
var chatterbotUrl = '{% url "chatterbot" %}';
with
var chatterbotUrl = "{% url 'chatterbot:chatterbot' %}";

I am getting same error 'chatterbot' is not a registered namespace. I am new to django framework. Tried above workaround but not able to solve it.

@RishikeshTeke Did you added chatterbot in installed_apps https://chatterbot.readthedocs.io/en/stable/django/index.html#installed-apps

@vkosuri Yes it is included inside settings.py file. Following is the content

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'chatterbot.ext.django_chatterbot',
'example_app',
)

I have solved problem by replacing var chatterbotUrl = '{% url "chatterbot" %}'; by var chatterbotUrl = '{% url "chatterbot:chatterbot" %}'; on line 46 in template/app.html

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ArunSingh1 picture ArunSingh1  路  3Comments

decode007 picture decode007  路  4Comments

proguy627 picture proguy627  路  3Comments

hochochoc picture hochochoc  路  3Comments

cesarandreslopez picture cesarandreslopez  路  4Comments