原创 sqlachemy執行sql 語句,返回結果轉json

from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker engine = create_engine('mysql://root:***

原创 vue TypeError: e.call is not a function

最近運行vue項目老是提示TypeError: e.call is not a function 一運行到該頁面就會提示這個錯誤,雖然頁面功能都沒受到影響,但是是個隱患,也煩人, 一層層刪除掉組件,可最後任然提示錯誤 查詢文檔發現是定義了

原创 ubuntu配置django環境

1、申請雲主機,部署ubuntu主機,開放22端口 2、系統Ubuntu16.04,系統自帶2個版本的python,一個是python2.7,一個是python3.5 安裝pip工具 sudo apt-get install python

原创 __str__ returned non-string (type NoneType)

用戶表是Django中核心的表,當這個表類字段中有一個這樣的函數 1 2 def __str__(self):     return self.name 在Django用戶表設計時候有個字段容易犯這個失誤,雖然表字段約束沒錯 1

原创 sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) near "DROP": syntax error

這就是flask 對應 sqlite的一個坑 解決方式 1.修改migrations/evn.py中的方法, 添加 render_as_batch=True 2、刪除version下面的各種東西, 3、重新執行python manage

原创 django 安裝xadmin 替代admin

01-下載源碼 安裝 https://github.com/sshwsfc/xadmin  Install Xadmin is best installed via PyPI. To install the latest version

原创 RuntimeError: You called this URL via POST, but the URL doesn’t end in a slash and you have A

解決方法: RuntimeError: You called this URL via POST, but the URL doesn’t end in a slash and you have APPEND_SLASH set. act

原创 API: jquery-serialize-object is required to add form data to an existing data object

使用 Semantic-Ui API behaviors 時  出現上述問題,原因是如果請求提交的是表單,需要使用 serializeForm 設置。否則 input 的數據都不會發送到服務器。 以上的用法如果不注意看文檔中這一行提示:

原创 TypeError: can't subtract offset-naive and offset-aware datet

在使用Django時,默認是開啓對多時區的支持的,在獲取時間的時候會是如下形式: datetime.datetime(2014, 4, 18, 15, 37, 7, tzinfo=<UTC>) 我們可以利用django.utils.tim

原创 Pycharm安裝擴展包

Python中第三方的庫(library)、模塊(module),包(package)的安裝方法以及ImportError: No module named 1.pip install ....   一般的pycharm都自帶有pip,如

原创 Ubuntu16 安裝python3.7.1 報錯ModuleNotFoundError: No module named '_ctypes'

sudo apt-get install libffi-dev 重新安裝即可 make && make install 其他系統 yum install libffi-devel sudo dnf install libffi-devel

原创 Pycharm Github 備份

1、註冊github賬號 2、安裝git 3、PyCharm的File -> Setting,找到github,輸入用戶名和密碼,點擊test 4、設置Git,把路徑設置爲本機git安裝路徑(git.exe的路徑):  這個可以自動偵測

原创 django 擴容user信息

from django.contrib.auth.models import User class Employee(models.Model): user = models.OneToOneField(User, prima

原创 Python中獲得當前目錄和上級目錄

獲取當前文件的路徑: from os import path d = path.dirname(__file__) #返回當前文件所在的目錄 # __file__ 爲當前文件, 若果在ide中運行此行會報錯,可改爲 #

原创 python-TypeError: Object of type 'Decimal' is not JSON serializable 報錯

j = json.dumps(xxxxxxx,cls=DecimalEncoder) class DecimalEncoder(json.JSONEncoder): def default(self, o):