I have change my urls.py following the instruction
from django.conf.urls import url """ImportError: cannot import name 'url' from 'django.conf.urls'"
the solution is to replace the from django.conf.urls import url by
from django.urls import re_path
and
urlpatterns = [
path('admin/', admin.site.urls),
re_path(r'^api/data/$', get_data , name='api-data'),
re_path('', index, name='index'),
]
I have followed the instruction
In my c:\learning_log\learning_log\urls.py
from django.conf.urls import include
from django.contrib import admin
from django.urls import re_path # add for the correction
urlpatterns = [
re_path(r'^admin/', include(admin.site.urls)), # correct replace url by re_path
re_path(r'', include('learning_logs.urls', namespace='learning_logs')), # correct replace url by re_path
]
this create a lot of error
(ll_env) C:\learning_log>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\EALALIN\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 1038, in _bootstrap_inner
self.run()
File "C:\Users\EALALIN\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 975, in run
etc ....
What is strange is that the previous configuration was working very well before including "from django.conf.urls import url "
from django.conf.urls import include
from django.contrib import admin
#from django.urls import re_path # add for the correction
from django.urls import re_path as url
urlpatterns = [
url(r'^admin/', include(admin.site.urls)), # correct replace url by re_path
url(r'', include('learning_logs.urls', namespace='learning_logs')), # correct replace url by re_path
]
but I still have in the runserver
File "C:\learning_log\learning_log\urls.py", line 51, in <module>
url(r'^admin/', include(admin.site.urls)), # correct replace url by re_path
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\learning_log\ll_env\Lib\site-packages\django\urls\conf.py", line 28, in include
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Passing a 3-tuple to include() is not supported. Pass a 2-tuple containing the list of patterns and app_name, and provide the namespace argument to include() instead.
Side note: When posting code or errors here, surround the code (or text) between lines of three backtick - ` characters. This means you’ll have a line of ```, then the code, then another line of ```. This forces the forum software to keep your code properly formattted. (I’ve taken the liberty of editing your original posts, please remember to do this in the future.)