[Fixed]-When i run my django project on terminal i get the AttributeError: 'str' object has no attribute 'regex'

1👍

In one of your urls.py files, you have a string in the list of URL patterns. This could be because you forgot to remove the prefix when you switched from patterns(prefix, ...) to a list of url()s.

You need to look through your urls.py and find something like:

urlpatterns =[
    '' # <- this is the problem, remove this string
    url(...)
    url(...)
]

Unfortunately, it’s not possible for us to tell which urls.py the problem is in. You could try commenting out the includes() one by one. If the error stops, then you’ve found the one that’s causing the problem.

In Django 1.10, the url checks have improved slightly, the check_pattern_startswith_slash won’t fail any more, and you’ll get a specific warning about the string instead.

Leave a comment