Don’t panic in case of data tilt, teach you to easily obtain the slope of table tilt>>>
Perform the import operation
from django.conf.urls import patterns, include, url
The following error is reported:
ImportError: cannot import name 'patterns'
The reason is that the actual use of the new version of Django has removed patterns, and the original code will be changed by Baidu
from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'superlists.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)), )
To be amended as follows:
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = ['',
# Examples:
url(r'^$', 'lists.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
# url(r'^admin/', include(admin.site.urls))
]
The following error is reported during execution
TypeError: view must be a callable or a list/tuple in the case of include().
The modification code is as follows:
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = ['',
# Examples:
url(r'^$', include('lists.views.home_page'), name='home'),
# url(r'^blog/', include('blog.urls')),
# url(r'^admin/', include(admin.site.urls))
The following error is reported during re execution
ModuleNotFoundError: No module named 'lists.views.home_page'; 'lists.views' is not a package
Import home from views in lists directory_ Page, with the following modifications
from django.conf.urls import include, url
from django.contrib import admin
from lists.views import home_page
urlpatterns = ['',
# Examples:
url(r'^$', home_page, name='home'),
# url(r'^blog/', include('blog.urls')),
# url(r'^admin/', include(admin.site.urls))
]
The following error is reported during re execution
Creating test database for alias 'default'...
SystemCheckError: System check identified some issues:
ERRORS:
?: (urls.E004) Your URL pattern '' is invalid. Ensure that urlpatterns is a list of url() instances.
HINT: Try removing the string ''. The list of urlpatterns should not have a prefix string as the first element.
System check identified 1 issue (0 silenced).
This is caused by the addition of [‘,] in urlpatterns. After the removal of [‘], the execution will run normally
Similar Posts:
- When deploying Django project on centos7, there will be an error of importerror: cannot import name middlewaremin
- Django @csrf_exempt Cannot work in class view (Django @csrf_exempt not working in class View)
- How to Solve Django xadmin installation Error [7 Types of Errors]
- [Solved] xadmin Error: ImportError: cannot import name ‘DEFAULT_FORMATS’ from ‘import_export.admin’ (/home/lijun/app/hippo/hippo_api/venv/lib/python3.8/site-packages/import_export/admin.py)
- Django startup error: generator expression must be parentized
- Django admin Error: ‘WSGIRequest’ object has no attribute ‘user’
- “No module named context_processors”
- [Solved] DjangoORM Run python manage.py makemigrations Error: no changes detected
- [Solved] ImportError: cannot import name pywrap_tensorflow
- [Django CSRF tutorial] solve the problem of forbidden (403) CSRF verification failed. Request aborted