Django importError (無法引進名稱 'six')



serializer.py:

from .models import stock
from rest_framework import serializers

class StockSerializer(serializers.ModelSerializer):
class Meta:
model = stock
fields = ('id', 'stock_name', 'price', 'stock_gain', 'market_name')

views.py:

from django.shortcuts import render
from rest_framework import viewsets, filters
from .seriaizer import StockSerializer
from .models import stock
from django_filters.rest_framework import DjangoFilterBackend

class StockViews(viewsets.ModelViewSet):
queryset = stock.objects.all()
serializer_class = StockSerializer
filter_backends = (DjangoFilterBackend, filters.OrderingFilter)
search_fields = ('stock_name',)
ordering = ('stock_gain',)

urls.py:

from django.contrib import admin
from django.conf.urls import url
from django.urls import path, include
from rest_framework import routers
from restapp.views import StockViews
from restapp import views

router = routers.DefaultRouter()
router.register('stock', views.StockViews)
urlpatterns = [
url(r'', include(router.urls)),
path('admin/', admin.site.urls),
]

我想到了这个错误:ImportError:无法从"django.utils"(C:\Users\hajar\OneDrive \Desktop\stockm\env\lib\site packages\django\utils_init_.py(导入名称"six">

我安装了六个pip安装六个

但不工作????有人能帮我吗?!

此错误可能是由于您在项目中使用的依赖项的旧版本,如djangorestframeworkdjango-cors-headers。请将其升级到最新版本。以下内容可能会有所帮助

pip install --upgrade django-cors-headers
pip install --upgrade djangorestframework

相关内容

  • 没有找到相关文章

最新更新