1
votes

I want to use re_path from django.urls, django doc says I can use this from django version 2,

From the error I came to know that I am using django version 2.0.6.

But I am not able to re_path

ImportError at /

cannot import name 're_path'

Request Method: GET Request URL: http://djangosite.com/ Django Version: 2.0.6 Exception Type: ImportError Exception Value:

cannot import name 're_path'

Exception Location: /home/sugushiva/myproject/filope/blogs/urls.py in , line 1 Python Executable: /usr/bin/python3

In main urls.py

from django.contrib import admin
from django.urls import path, re_path,include

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

in blogs.urls

from django.db import re_path
from .models import blogindex

urlpatterns = [
    re_path('^$',blogindex)
]
1
We're not going to be able to help you much unless you show us your actual code where you are trying to import this module...solarissmoke
@solarissmoke as ssh and google compute engine I am not able to copy and and paste the code. but I will type the code hereSugumar Venkatesan
@solarissmoke sir I updated question, please tell me sir if you want more detailsSugumar Venkatesan

1 Answers

4
votes

You are importing the wrong path in blogs/urls.py.

from django.db import re_path

Should instead be:

from django.urls import re_path