4

I am using django 1.9 version and I wanted to implement ajax search in my application. In the documentation it is says to add the urls to the root url patterns.

url(r'^ajax_search/',include('ajax_search.urls')),`

Then I am getting an import error as follows:

File "/usr/local/lib/python2.7/dist-packages/django_ajax_search-1.5.1-py2.7.egg/ajax_search/urls.py", line 1, in <module>
    from django.conf.urls.defaults import *
ImportError: No module named defaults

Can any one help me solve this issue?

JRodDynamite
  • 12,325
  • 5
  • 43
  • 63
Swathi Pantala
  • 335
  • 1
  • 6
  • 13

2 Answers2

3

django.conf.urls.defaults has been removed from Django 1.6 onwards.

django-ajax-search package was last updated in 2013. The package has not been updated for a long and will not work smoothly for Django 1.9

Either you can find another package or you can manually update it.

JRodDynamite
  • 12,325
  • 5
  • 43
  • 63
0

django.conf.urls.defaults is deprecated in Django 1.4, later removed in Django 1.6. Read this. And the package you are using has the urls not compatible with Django 1.9. According to the Django 1.9 documentation you should define your urls.py as,

from django.conf.urls import url

from . import views

urlpatterns = [
    url(r'^articles/2003/$', views.special_case_2003),
    url(r'^articles/([0-9]{4})/$', views.year_archive),
    url(r'^articles/([0-9]{4})/([0-9]{2})/$', views.month_archive),
    url(r'^articles/([0-9]{4})/([0-9]{2})/([0-9]+)/$', views.article_detail),
]

UPDATE:

You can modify your urls.py as below to make this working,

from django.conf.urls import url, include
from ajax_search import views as as_views

ajax_search_urlpatterns = [
    url(r'^xhr_search$','as_views.xhr_search'),
    url(r'^search/', 'as_views.search'),
]

urlpatterns = [
    url(r'^ajax_search/',include(ajax_search_urlpatterns)),
]
Parag Tyagi
  • 8,780
  • 3
  • 42
  • 47