ArtOfEngineer/PythonDjango-PostgreSQL-VueJS

ImportError: cannot import name 'url' from 'django.conf.urls’

Opened this issue · 0 comments

I get this error when i use urls.py.
I fix this issue follow the instruction as below:
https://stackoverflow.com/questions/70319606/importerror-cannot-import-name-url-from-django-conf-urls-after-upgrading-to

my urls.py looks like below:

DjangoAPI/urls.py


"""
URL configuration for DjangoAPI project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/5.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path

from django.urls import re_path , include

urlpatterns = [
    path('admin/', admin.site.urls),
    re_path(r'^',include('EmployeeApp.urls'))
]

DjangoAPI/EmployeeApp/urls.py


from django.urls import re_path
from EmployeeApp import views

from django.conf.urls.static import static
from django.conf import settings


urlpatterns = [
    re_path(r'^department$',views.departmentApi),
    re_path(r'^department/([0-9]+)$',views.departmentApi),

    re_path(r'^employee$',views.employeeApi),
    re_path(r'^employee/([0-9]+)$',views.employeeApi),

    re_path(r'^employee/savefile',views.SaveFile)
]+static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)