# from django.conf.urls import url """ImportError

**URL:** <https://forum.djangoproject.com/t/from-django-conf-urls-import-url-importerror/26399>\
**Category:** Getting Started\
**Created:** [December 24, 2023, 7:57pm UTC](https://forum.djangoproject.com/t/from-django-conf-urls-import-url-importerror/26399 "2023-12-24T19:57:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ealalin](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ealalin/32/17520_2.png) [@ealalin](https://forum.djangoproject.com/u/ealalin)\
**Post date:** [December 24, 2023, 7:57pm UTC](https://forum.djangoproject.com/t/from-django-conf-urls-import-url-importerror/26399/1 "2023-12-24T19:57:02Z")

</div>

I have seen the similar error [Django 4.0 url import error](https://forum.djangoproject.com/t/django-4-0-url-import-error/11065)

My Django version is 4.2.7

I have change my urls.py following the instruction

```auto
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

```auto
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

```auto
(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 "

best regards  
ealalin

---

<div class="post-metadata">

**Author:** ![ealalin](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ealalin/32/17520_2.png) [@ealalin](https://forum.djangoproject.com/u/ealalin)\
**Post date:** [December 24, 2023, 10:52pm UTC](https://forum.djangoproject.com/t/from-django-conf-urls-import-url-importerror/26399/2 "2023-12-24T22:52:23Z")

</div>

I Have try this work around :

```auto
from django.urls import re_path as url

```

my urls.py

```auto
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

```auto
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.

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [December 25, 2023, 3:20am UTC](https://forum.djangoproject.com/t/from-django-conf-urls-import-url-importerror/26399/3 "2023-12-25T03:20:21Z")

</div>

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.)

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [December 25, 2023, 3:34am UTC](https://forum.djangoproject.com/t/from-django-conf-urls-import-url-importerror/26399/4 "2023-12-25T03:34:06Z")

</div>

Review the docs at [django.urls functions for use in URLconfs | Django documentation | Django](https://docs.djangoproject.com/en/5.0/ref/urls/) to understand what the `path` and `re_path` functions do, and to understand how to update your url definitions.

Since you’re not using (or don’t need to use) regexes for your paths, you can use `path` instead of `re_path`.

Also read [The Django admin site | Django documentation | Django](https://docs.djangoproject.com/en/3.2/ref/contrib/admin/#hooking-adminsite-instances-into-your-urlconf)

Note: If you get a new/different error, please post the complete traceback.

---

<div class="post-metadata">

**Author:** ![ealalin](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ealalin/32/17520_2.png) [@ealalin](https://forum.djangoproject.com/u/ealalin)\
**Post date:** [December 27, 2023, 9:51pm UTC](https://forum.djangoproject.com/t/from-django-conf-urls-import-url-importerror/26399/5 "2023-12-27T21:51:15Z")

</div>

‘’’ The problem is resolved’‘’  
‘’’ into c:\learning\_log\learning\_log\urls.py I have ‘’’

from django.urls import include, re\_path  
from django.contrib import admin

urlpatterns = [  
re\_path(r’^admin/‘, admin.site.urls),  
re\_path(r’', include((‘learning\_logs.urls’, ‘learning\_logs’), namespace=‘learning\_logs’)),  
]

‘’‘into c:\learning\_log\learning\_logs\urls.py I have’‘’

from django.urls import re\_path as url2  
from . import views

urlpatterns = [  
# home page  
url2(‘^$’, views.index, name=‘index’),

]

‘’’ I have my home page in c:\learning\_log\learning\_logs\template\learning\_logs\index.html ‘’’
