Home > Software design >  ModuleNotFoundError: No module named 'rest_framework' python3 django
ModuleNotFoundError: No module named 'rest_framework' python3 django

Time:10-30

I copied code from blog and i got this error. Actually i am newbie in django and stackoverflow too. i copied code from github blog so easly i can reach to my aim.

line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
    ModuleNotFoundError: No module named 'rest_framework'

Copied code is

from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, UserManager
from phonenumber_field.modelfields import PhoneNumberField
   
)    



class Address(models.Model):
    address_line = models.CharField(
        _("Address"), max_length=255, blank=True, null=True
    )
    street = models.CharField(
        _("Street"), max_length=55, blank=True, null=True)
    city = models.CharField(_("City"), max_length=255, blank=True, null=True)
    state = models.CharField(_("State"), max_length=255, blank=True, null=True)
    postcode = models.CharField(
        _("Post/Zip-code"), max_length=64, blank=True, null=True
    )
    country = models.CharField(
        max_length=3, choices=COUNTRIES, blank=True, null=True)

  
       
       
       
        return address
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

CodePudding user response:

pip3 install djangorestframework

In settings.py

installed app

'rest_framework',
  • Related