2019年8月14日 星期三

git lab 更新遇到問題

若要git pull時遇到Please commit your changes or stash them before you merge.錯誤提示時
代表你這裡已有做更動但未儲存更新
如果要直接下載上面的文件覆蓋自己這邊的
執行:
git reset --hard
git pull
即可成功
其他辦法可參考以下網站
https://blog.csdn.net/liuchunming033/article/details/45368237

https://blog.csdn.net/iefreer/article/details/7679631

https://ithelp.ithome.com.tw/articles/10188789


2019年8月6日 星期二

更新新聞資料庫

django內對model有做變更時,須執行makemigrations指令.
其目的是將對model做的改動(model是django內建構資料庫的函式)建構到資料庫內.
無論是新增或改動抑或是刪除都需要執行,不然runserver或是有用到資料庫的頁面可能會出現error.

新增新聞:
http://localhost:8000/contentdb/add
更正
http://localhost:8000/update/add

2019年7月23日 星期二

mysql安裝

https://dev.mysql.com/downloads/installer/

選5.7.27 離線安裝版
勾選同意>>下一步

以上為要安裝的mysql要的環境
點選"Execute"進行安裝


點選yes>>next>>execute

選擇上面那個並按next

照此設定>>next

先預設一組密碼>>next

Name改為MySQL>>next

完成!!
之後都按next 登入剛才設的密碼按check>>execute

下面那個不要勾>>finish




2019年7月22日 星期一

遇到的問題及解決方法

報錯環境python=3.6,django=2.2,PyMySQL=0.9.3 …… django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.

解決方法: Django連接MySQL時默認使用MySQLdb驅動,但MySQLdb不支持Python3,因此這裡將MySQL驅動設置為pymysql,使用pip install pymysql 進行安裝,然後在工程文件__init__.py添加以下代碼即可。
 #安裝pymysql

pip install pymysql


#__init__.py
import pymysql
pymysql.install_as_MySQLdb()

\Lib\site-packages\django\db\backends\mysql\base.py
35.36行註解掉

\Lib\site-packages\django\db\backends\mysql\operations.py

146行decode()改為encode()

--------------------------------------------------------------

git lab

Git for Windows : 


載點:http://git-scm.com/download/win
安裝一路往下按next
使用git cmd
cd到你想放的資料夾
:

詳細:http://git-for-windows.github.io/
git參考:https://windsuzu.github.io/learn-git/














git clone '你的clone網址'
把專案clone到本地

git pull
從雲端更新本地檔案


git add -A

將本地檔案新增到.git(-A的意思所有操作都更新上去)

git commit -a -m 'xxxx'

xxx為註解 將.git 上傳到自己帳號的.git

git push

將檔案push到專案

注意: 所有有更變的檔案都會push上去(新增、刪除、修改)

Python Django (1)

為了專研要寫一個有檢索的摘要介面,決定用django來寫網頁.

python version : 3.7.4
django version : 2.2.3
mysql version: 5.7.26

安裝django
pip3 install django
未指定版本的話 會直接安裝2.2.3版本

目前進度:完成crawlar到db

釐清: project . app . urls. views . templates . model

疑惑: import model
http回傳值到哪裡

下一步:完成檢索系統

學習資源:
html :
https://pydoing.blogspot.com/2012/01/html-5-syntax.html
python :
http://www.runoob.com/python3/python3-tutorial.html (大推,類似工具書)
https://pydoing.blogspot.com/2012/10/python-tutorial.html

css :
http://zh-tw.learnlayout.com/
django:
https://djangogirlstaipei.gitbooks.io/django-girls-taipei-tutorial/ -djangogirl
https://ithelp.ithome.com.tw/articles/10199515 -it邦 BY
https://ithelp.ithome.com.tw/articles/10157091 -it邦 TP