# fotoable_api_test **Repository Path**: daofeng_dev/fotoable_api_test ## Basic Information - **Project Name**: fotoable_api_test - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: develop - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2023-12-19 - **Last Updated**: 2024-11-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 【项目安装】 mysql信息: 10.0.201.233 root/root 后台管理账号:fotoable/1qaz2wsx [最好新建一个虚拟环境] pyenv install 3.7.4 pyenv virtualenv 3.7.4 new-3.7.4 pyenv activate new-3.7.4 pip install -r requirements.txt pip install https://github.com/darklow/django-suit/tarball/v2 安装完成后,修改settings.py中DATABASE相关信息。 需要手动创建数据库。 项目运行 python manage.py makemigrations -记录修改 python manage.py migrate -创建表结构 python manage.py createsuperuser -创建后台管理员 python manage.py runserver 127.0.0.1:8002 项目启动成功后,便可以进入urls.py指定的路径了: 1,localhost:8002/admin 管理后台 ,使用createsuperuser创建的账号密码登录 2,localhost:8002/redoc 查看接口文档 3,localhost:8002/swagger 接口调试 4,localhost:8002/swagger.yaml 或 swagger.json 会将swagger.json/yaml下载到本地,该文件可以嵌入到wiki中 【注意事项】 参考资料:https://zhuanlan.zhihu.com/p/76920424 若直接运行上面的语句,应该会报错: File "/[your-path]/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 36, in raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__) django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3. 因为Django后台需要的包是mysqlclient, 而我们安装的是PyMySQL==0.9.3 目前解决办法: 按照错误信息提示,修改base.py,注释掉第35,36行 再次运行还会报错: File "/[your-path]/lib/python3.7/site-packages/django/db/backends/mysql/operations.py", line 146, in last_executed_query query = query.decode(errors='replace') AttributeError: 'str' object has no attribute 'decode' 根据错误信息提示,修改operations.py 第146行,将 query.decode 改为 query.encode。 也可以直接用brew安装mysqlclient,比较麻烦,问题还多。 另外,django-rest-swagger==2.1.2支持header添加token,在swagger界面可以调试需要token的接口;2.2.0版本是不支持的 djangorestframework==3.7.7 支持/docs 高版本报错TypeError: Expected a `coreapi.Document` instance https://blog.csdn.net/pushiqiang/article/details/73133745 django-rest-swagger==2.2.0 与2.1.1 页面样式不同 前端有路由,利用axios发送请求到后端django路由上, 根据路由读数据库返回数据