Solution skill
ImportError: cannot import name 'patterns' from 'django.conf.urls'
Complete solution
Fixes `ImportError: cannot import name 'patterns' from 'django.conf.urls'` in django. Use when the traceback points at django.conf.urls and names patterns, usually right after a Django upgrade. Not for 404s, reversed-URL NoReverseMatch errors, or 'No module named django' (that is a missing install).
ImportError: cannot import name 'patterns' from 'django.conf.urls'
TL;DR
Your code (or a dependency) still imports patterns from django.conf.urls, which Django removed in 1.10. Replace patterns('', ...) with a plain Python list of url() entries. If the import lives in a third-party package, upgrade that package to a version that supports your Django.
The error
ImportError: cannot import name 'patterns' from 'django.conf.urls'Fix it
Find every import of patterns: run grep -rn "from django.conf.urls import" --include=*.py . and note each file that pulls in patterns. Expected: You get a short list of files, usually urls.py files and maybe an old third-party package.
In your own code, replace the old call: patterns('', url(r'^$', view)) becomes a plain list [url(r'^$', view)]. The first string argument (the prefix) is simply dropped. Expected: urls.py imports cleanly and python manage.py check runs without the ImportError.
If the import is inside site-packages (a dependency), upgrade it: pip install -U [package]. Waliki, for example, fixed this in a later release. Expected: The dependency imports fine against your Django version.
As a last resort for an unmaintained package, pin Django below 1.10, but plan the migration since that Django is long out of support. Expected: App boots, with a note to revisit the pin.
When to use this
Use when the traceback points at django.conf.urls and names patterns, usually right after a Django upgrade.
When NOT to use this
Not for 404s, reversed-URL NoReverseMatch errors, or 'No module named django' (that is a missing install).
Version notes
patterns() existed up to Django 1.8, deprecated in 1.8, removed in 1.10. Any code importing it needs Django < 1.10 or a rewrite.
Why it happens
Django 1.10 deleted the patterns() helper along with the old string-view-prefix style. Old tutorials and old packages still import it, so upgrading Django past 1.9 breaks them at import time.
Edge cases
Some packages import patterns conditionally; a grep that finds nothing in your code means the culprit is a dependency, check pip freeze and the full traceback.
Evidence
A waliki user hit this exact ImportError after upgrading Django, because waliki imported patterns from django.conf.urls (mgaitan/waliki#126). The verified fix was to stop importing patterns and use a plain list of url() entries, which is what modern Django expects. This matches the official Django 1.10 release notes, which document the removal.
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_6bBqrZtOXww7wyFPG_Jwpw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">ImportError: cannot import name 'patterns' from 'django.conf.urls' <span>— Vectle</span></a>