'ModuleNotFoundError: No module named 'typing_extensions'

i am working in a blog site with django. my project urls.py code:

from django.contrib import admin
from django.urls import path
from.import views
urlpatterns = [
    path('admin/', admin.site.urls),
    path('',views.index,name="home"),
    path('login/',views.authlogin,name="login"),
    path('signup/',views.signup,name="signup"),
    path('contact/',views.contact,name="contact"),
    path('about/',views.about,name="about"),
    path('logout/',views.authlogout,name='logout'),
    path('dashboard/',views.dashboard,name='dashboard'),
    path('updatepost/<int:id>',views.update_post,name='updatepost'),
    path('addpost/',views.add_post,name='addpost'),
    path('delete/<int:id>',views.delete_post,name='deletepost'),
]

but it shows me

 File "C:\Users\ABU RAYHAN\Desktop\projects\miniblog\blog\urls.py", line 3, in <module>
    from.import views
  File "C:\Users\ABU RAYHAN\Desktop\projects\miniblog\blog\views.py", line 1, in <module>
    from typing_extensions import Required
ModuleNotFoundError: No module named 'typing_extensions'

i am new here pardon my mistake.



Solution 1:[1]

There must be an import from typing-extensions module in blog\views.py file on line 1

in your code. Use this command to install it

pip install typing-extensions

after that this issue will be resolved.

Solution 2:[2]

I had the same error.

Mine came from models.py

models.py

from typing_extensions import Required
from django.db import models


class nameOfModel(models.Model):
    nameOfField = models.CharField(max_length=255, Required=True)

Because I used Required=True, VSCode added automatically from typing_extensions import Required.

So I did this instead.

models.py

from django.db import models


class nameOfModel(models.Model):
    nameOfField = models.CharField(max_length=255, blank=False)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Faisal Nazik
Solution 2 AnonymousUser