Проблема с импортом DRF.responce - python
Я, копаясь в своём ПК, нашёл свой старый проект, который использует Django REST Framework. Но при его настройке возникла проблема с импортом, которую не могу решить.
views.py
from django.shortcuts import render, redirect, get_object_or_404
from rest_framework.responce import Responce
from rest_framework.view import APIView
from django.contrib import messages
from .models import Blog, Tag
from .serializer import BlogSerializer
from .forms import UserLoginForm, UserRegisterForm
# Create your views here.
class BlogAPIView(APIView):
def get(self, request):
return Responce({'result': 'True'})
def main_render(request):
return render(request, 'main/index.html')
def blog_render(request):
return render(request, 'main/blog.html', {'blog': Blog.objects.all().order_by('-id')})
def contacts_render(request):
return render(request, 'main/contacts.html')
def for_posts(request):
if request.method == "POST":
form = Blog()
form.post_id = request.POST.get('id')
form.title = request.POST.get('title')
form.file = request.POST.get('image')
form.description = request.POST.get('description')
form.date = request.POST.get('date')
form.user = request.POST.get('user')
form.save()
return redirect('blog')
return render(request, 'main/addpost.html')
def blog_id(request, id_blog : int):
id_setting = get_object_or_404(Blog, id = id_blog)
return render(request, 'main/blog_id.html', {'id_setting': id_setting, 'id': id_blog, 'blog': Blog.objects.all()})
Вывод в консоль:
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1016, in _bootstrap_inner
self.run()
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\commands\runserver.py", line 134, in inner_run
self.check(display_num_errors=True)
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 475, in check
all_issues = checks.run_checks(
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\checks\registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\checks\urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver
return check_method()
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\urls\resolvers.py", line 494, in check
for pattern in self.url_patterns:
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\functional.py", line 57, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\urls\resolvers.py", line 715, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\functional.py", line 57, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\urls\resolvers.py", line 708, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Users\letsp\OneDrive\Документы\tahysgyr.dev\tahysgyr\tahysgyr\urls.py", line 18, in <module>
from main import views
File "C:\Users\letsp\OneDrive\Документы\tahysgyr.dev\tahysgyr\main\views.py", line 2, in <module>
from rest_framework.responce import Responce
ModuleNotFoundError: No module named 'rest_framework.responce'
C:\Users\letsp\OneDrive\Документы\tahysgyr.dev\tahysgyr\tahysgyr\settings.py changed, reloading.
Watching for file changes with StatReloader
Performing system checks...
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1016, in _bootstrap_inner
self.run()
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\commands\runserver.py", line 134, in inner_run
self.check(display_num_errors=True)
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\base.py", line 475, in check
all_issues = checks.run_checks(
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\checks\registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\checks\urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver
return check_method()
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\urls\resolvers.py", line 494, in check
for pattern in self.url_patterns:
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\functional.py", line 57, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\urls\resolvers.py", line 715, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\functional.py", line 57, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\urls\resolvers.py", line 708, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\letsp\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Users\letsp\OneDrive\Документы\tahysgyr.dev\tahysgyr\tahysgyr\urls.py", line 18, in <module>
from main import views
File "C:\Users\letsp\OneDrive\Документы\tahysgyr.dev\tahysgyr\main\views.py", line 2, in <module>
from rest_framework.responce import Responce
ModuleNotFoundError: No module named 'rest_framework.responce'
Модуль rest_framework
установлен.
Источник: Stack Overflow на русском