I am working with django 1.9 and I am currently coding - in Windows Command Prompt - python manage.py makemigrations
and the error:
AttributeErr
Also make sure to remove the beginning empty url pattern--can be overlooked when migrating your urls.
urlpatterns = ['', # <== this blank element ('') produces the error.
...
]
For the curious, I found this out by adding a warning to the check_pattern_startswith_slash
method in the django.core.checks.urls
module:
def check_pattern_startswith_slash(pattern):
"""
Check that the pattern does not begin with a forward slash.
"""
if not hasattr(pattern, 'regex'):
warning = Warning(
"Invalid pattern '%s'" % pattern,
id="urls.W002",
)
return [warning]
And, sure enough, I got a bunch of warnings like this:
?: (urls.W002) Invalid pattern ''