ImportError: no module by default

I am using django version 1.9 and I wanted to implement ajax search in my application. The documentation says that you need to add URLs to root url patterns.

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

Then I get the 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 someone help me solve this problem?

+4
source share
2 answers

django.conf.urls.defaults was removed from Django 1.6 onwards .

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

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

+3
source

django.conf.urls.defaults Django 1.4, Django 1.6. this. , , urls, Django 1.9. Django 1.9 , urls.py ,

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:

urls.py, , ,

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)),
]
0

All Articles