python+vue前后端分离-实战演练

版权声明:看上的,随便转载。 https://blog.csdn.net/Android_app/article/details/80318095

MxShop - resource和online-store,

提示:ModuleNotFoundError: No module named ‘MxShop’

解决思路:换个路径就好 sys.path.append(“D:\py_work\x24pzv\MxShop - resource\”)

提示:To use ESLint please install eslint by running ‘npm install eslint’ in the workspace folder online-store

解决思路:安装即可 npm install eslint

更改前端api指向

解决思路:src/api/api.js文件下
let host = ‘http://127.0.0.1‘;

运行node server.js出现错误:Module build failed: Error: Cannot find module ‘node-sass’

解决思路:安装对应模块即可(node-sass)

出现:Error: Cannot find module ‘express’

解决思路:在项目路径下:cmd窗口运行:“npm install”安装所有依赖

打开:http://127.0.0.1:8000/goods/

出现:django.template.exceptions.TemplateDoesNotExist: django/forms/widgets/number.html
解决思路:在对应路径查看是否对应文件存在即可

出现redis.exceptions.ConnectionError: Error 10061 connecting to 127.0.0.1:6379. 由于目标计算机积极拒绝,无法连接。.

解决思路:连接对应的redis即可,,源码中默认是连接本地的redis

Redis is running in protected mode because protected mode is enabled

解决思路:去掉redis保护模式,在redis配置中配置如下:

protected-mode no 

FileNotFoundError: [Errno 2] No such file or directory: ‘E:\Python36\lib\site-packages\django-2.0-py3.6.egg\django\views\templates\technical_404.html’,,FileNotFoundError: [Errno 2] No such file or directory: ‘E:\Python36\lib\site-packages\django-2.0-py3.6.egg\django\views\templates\technical_500.html’

解决思路:在对应目录下建立对应文件即可

进行D:\py_work\x24pzv\MxShop - resource>python manage.py migrate

出现以下异常提示:

System check identified some issues:
WARNINGS:
?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default'
        HINT: MySQL's Strict Mode fixes many data integrity problems in MySQL, such as data truncati
on upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. S
ee: https://docs.djangoproject.com/en/2.0/ref/databases/#mysql-sql-mode
Operations to perform:
  Apply all migrations: auth, authtoken, contenttypes, goods, sessions, trade, user_operation, users
, xadmin
Running migrations:
...

运行 D:\py_work\x24pzv\MxShop - resource>python manage.py makemigrations

出现以下异常提示:

Migrations for 'goods':
  apps\goods\migrations\0009_auto_20180510_1143.py
    - Rename table for goodscategorybrand to goods_goodsbrand
Migrations for 'users':
  apps\users\migrations\0003_auto_20180510_1143.py
    - Alter field last_name on userprofile

提示 django.db.utils.OperationalError: (1049, “Unknown database ‘mxshop’”)

解决思路:新建mxshop数据库即可

出现:

File "E:\Python36\lib\site-packages\MySQLdb\connections.py", line 204, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (1045, "Access denied for user 'root'@'61.144.42.90' (using passwo
rd: YES)")

解决思路:在MxShop/settings.py修改密码

出现异常提示:

File "E:\Python36\lib\site-packages\rest_framework\schemas\generators.py", line 262, in __init__
    assert coreapi, '`coreapi` must be installed for schema support.'
AssertionError: `coreapi` must be installed for schema support.

解决思路:安装coreapi即可

出现异常提示

  File "D:\py_work\x24pzv\MxShop - resource\apps\utils\yunpian.py", line 4, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

解决思路:安装requests模块即可

出现异常提示

在文件\extra_apps\xadmin\plugins\language.py

  File "D:\py_work\x24pzv\MxShop - resource\extra_apps\xadmin\plugins\filters.py", line 10, in <modu
le>
    from django.db.models.sql.query import LOOKUP_SEP, QUERY_TERMS
ImportError: cannot import name 'QUERY_TERMS'

解决思路:

//把:
from django.db.models.sql.query import LOOKUP_SEP, QUERY_TERMS
//改为:
from django.db.models.sql.query import LOOKUP_SEP
from django.db.models.sql.constants import QUERY_TERMS

出现异常提示:

File "D:\py_work\x24pzv\MxShop - resource\extra_apps\xadmin\views\dashboard.py", line 286, in __init__    *args, **kwargs)
TypeError: __init__() takes 1 positional argument but 6 were given

解决思路:dashboard.py 的init 修改为只有一个参数

出现异常提示:

ModuleNotFoundError: No module named 'django.core.urlresolvers'

解决思路:
简单来说,原因就是:django2.0 把原来的 django.core.urlresolvers 包 更改为了 django.urls包,所以我们需要把导入的包都修改一下就可以了。
extra_apps/xadmin/base.py
extra_apps/xadmin/lists.py

Django在根据models生成数据库表时报 init() missing 1 required positional argument: ‘on_delete’

解决思路:在以下文件中进行修改

extra_apps\xadmin\plugins\sortablelist.py
\extra_apps\xadmin\plugins\topnav.py
\extra_apps\xadmin\plugins\relate.py
extra_apps\xadmin\plugins\details.py
extra_apps/xadmin/models.py
apps/goods/migrations/models.py
apps/trade/migrations/models.py
apps/user_operation/models.py

herobook=models.ForeignKey(‘BookInfo’,on_delete=models.CASCADE,)
即在外键值的后面加上 on_delete=models.CASCADE

项目

MxShop - resource

apps
db_tools
extra_apps
media
MxShop
static
templates
db.sqlite3
manage.py
requirements.txt

online-store

mock
node_modules
src
package.json
package-lock.json
postcss.config.js
proxy.js
README.md
server.js
template.html
webpack.config.js
webpack.prod.js
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页