Django知识小问答
Django知识小问答
关于makemigrations
问:我用python manage.py makemigrations怎么没能将我的model文件生成数据?
答:可以給我看下model的文件目录吗?
问:目录是这样的
代码语言:javascript复制(venv) G:gitbigbooombigboommcitizen>tree /f
卷 study 的文件夹 PATH 列表
卷序列号为 0000000F B64E:66E1
G:.
models.py
models.pyc
__init__.py
__init__.pyc
答:嗯嗯,我知道,我想你应该是少了一个migrations的文件夹吧,所以他不知道你需要生成migrations,你试试在citizen文件夹下面建一个migrations,记得要在里面加一个init.py哦,不然也是不可以的
问:啊,可以了~~ Good Job
代码语言:javascript复制(venv) G:gitbigbooombigboomm>python manage.py makemigrations
Migrations for 'citizen':
citizenmigrations 001_initial.py:
- Create model Citizen
答:其实,一般Django中建app建议用
代码语言:javascript复制
## cryptography 错误
报`RuntimeError: cryptography is required for sha256_password or caching_sha2_password`错:
File “C:UsersshikanonDesktop新建文件夹venvlibsite-packagespymysqlconnections.py”, line 325, in init self.connect() File “C:UsersshikanonDesktop新建文件夹venvlibsite-packagespymysqlconnections.py”, line 599, in connect self._request_authentication() File “C:UsersshikanonDesktop新建文件夹venvlibsite-packagespymysqlconnections.py”, line 882, in _request_authentication auth_packet = _auth.caching_sha2_password_auth(self, auth_packet) File “C:UsersshikanonDesktop新建文件夹venvlibsite-packagespymysql_auth.py”, line 264, in caching_sha2_password_auth data = sha2_rsa_encrypt(conn.password, conn.salt, conn.server_public_key) File “C:UsersshikanonDesktop新建文件夹venvlibsite-packagespymysql_auth.py”, line 142, in sha2_rsa_encrypt raise RuntimeError(“cryptography is required for sha256_password or caching_sha2_password”) RuntimeError: cryptography is required for sha256_password or caching_sha2_password
代码语言:javascript复制
只要安装`cryptography`包就可以了:
```pip install cryptography
windows 二进制包下载
https://www.lfd.uci.edu/~gohlke/pythonlibs/