[Django]-Django 1.9 url include AttributeError 'str' object has no attribute 'regex'

2👍

Shouldn’t you import include as well here from django.conf.urls import url, include ? I mean instead of having import, you should have include, I think.

2👍

I had a block of code commented out as a string in myapp/urls.py which was causing the issue:

from django.conf.urls import url

from myapp.views import IndexView

#app_name = 'myapp'

urlpatterns = [
  url(r'^$', IndexView.as_view(), name='index'),

  '''

  ...some old code from the Django 1.7.6 config

  '''
]

Django is attempting to read the string as a url object, which was causing the error.

Removing the string fixed the problem.

0👍

try using

from django.conf.urls import url, include

instead

from django.conf.urls import url, import

Leave a comment