標籤:mysql linux web django
問題 1:
raise ImproperlyConfigured("settings.DATABASES is improperly configured. " django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
解決思路:
請先確認DATABASES節點中配置正常,
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/59/6C/wKiom1TSQMvSQKTUAADGnYwV4GE730.jpg" title="2015-02-04 23_22_32.png" alt="wKiom1TSQMvSQKTUAADGnYwV4GE730.jpg" />
請檢查是否有多少 settings.py檔案.如果是請逐個檢查對應節點.
問題 2:
ImportError: No module named XXX
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/59/69/wKioL1TSQaCQiJZKAABqn_7sVDs355.jpg" title="2015-02-04 23_48_3.png" alt="wKioL1TSQaCQiJZKAABqn_7sVDs355.jpg" />
解決思路:
請確認這裡到底該不該用include
問題3:
Warning:
Incorrect string value: ‘\xE5\xBC\xA0\xE4\xB8\x89‘ for column ‘username‘ at row 1
解決:
很明顯,是因為字元亂碼的問題.造成的。
所以需要mysql支援中文,那麼就去更改mysql的字元集.
方式一: 在建立時就指定預設如:
mysql> create database test default charset=utf8;
然後再同步產生sql:
>>> python manage.py syncdb
方式二:
mysql > ALTER DATABASE bugzero_db CHARACTER SET utf-8;
這種方式只有在資料庫中沒有table的情況下才work
方式三:
-
mysql> SET character_set_client = utf8 ;
-
mysql> SET character_set_connection = utf8 ;
-
mysql> SET character_set_database = utf8 ;
-
mysql> SET character_set_results = utf8 ;
-
mysql> SET character_set_server = utf8 ;
-
mysql> SET collation_connection = utf8 ;
-
mysql> SET collation_database = utf8 ;
-
mysql> SET collation_server = utf8 ;
但是這種方法在發送查詢或進行與mysql互動時最好還是要加:
SET NAMES ‘utf8‘;
相當於:
-
SET character_set_client = utf8;
-
SET character_set_results = utf8;
-
SET character_set_connection = utf8;
不然還是不正常工作.
Forbidden (403)
CSRF verification failed. Request aborted.
Help
Reason given for failure:
CSRF token missing or incorrect.
In general, this can occur when there is a genuine Cross Site Request Forgery, or when Django‘s CSRF mechanism has not been used correctly. For POST forms, you need to ensure:
Your browser is accepting cookies.
The view function uses RequestContext for the template, instead of Context.
In the template, there is a {% csrf_token %} template tag inside each POST form that targets an internal URL.
If you are not using CsrfViewMiddleware, then you must use csrf_protect on any views that use the csrf_token template tag, as well as those that accept the POST data.
You‘re seeing the help section of this page because you have DEBUG = True in your Django settings file. Change that to False, and only the initial error message will be displayed.
You can customize this page using the CSRF_FAILURE_VIEW setting.
解決方案:開發過程中可暫時注釋settings.py中的
‘django.middleware.csrf.CsrfViewMiddleware‘,
由於剛剛接觸python , django, mysql也是頭一次接觸所以可能遇到的都是小白問題,為了自己備忘,說不定也可以協助到各位.
連載 ing..歡迎各位補充.
本文出自 “狼之魂” 部落格,請務必保留此出處http://itwolf.blog.51cto.com/3286625/1611699
Django Python MySql 問題集錦