Django Python MYSQL Problem Collection

Source: Internet
Author: User
Tags python mysql

Question 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.

Solution Ideas :

Please make sure that the Databases node is configured properly.

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 "/>


Check to see if there are any settings.py files. If yes, check the corresponding node individually.


Question 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 "/>

Solution Ideas :

Please make sure the include is not used here.


Question 3:

Warning:

Incorrect string value: ' \xe5\xbc\xa0\xe4\xb8\x89 ' for column ' username ' at row 1

Solve:

Obviously, it is because of the problem of character garbled. caused.

So if you need MySQL to support Chinese, then go to change the MySQL character set.

Mode one: At the time of creation, specify the default as:

Mysql> CREATE DATABASE test default Charset=utf8;

Then generate the SQL synchronously:

>>> python manage.py syncdb


Way two:

MySQL > ALTER DATABASE bugzero_db CHARACTER SET utf-8;

This approach works only if there is no table in the database


Way three:


  1. MySQL> SET character_set_client = UTF8 ;

  2. MySQL> SET character_set_connection = UTF8 ;

  3. MySQL> SET character_set_database = UTF8 ;

  4. MySQL> SET character_set_results = UTF8 ;

  5. MySQL> SET character_set_server = UTF8 ;


  6. MySQL> SET collation_connection = UTF8 ;

  7. MySQL> SET collation_database = UTF8 ;

  8. MySQL> SET collation_server = UTF8 ;

But this approach is best when sending queries or interacting with MySQL:

SET NAMES ' UTF8 ';

Equivalent:

    1. SET character_set_client = UTF8;

    2. SET character_set_results = UTF8;

    3. SET character_set_connection = UTF8;

Otherwise it is not working properly.





Forbidden (403)

CSRF verification failed. Request aborted.
Help

Reason given for failure:

CSRF token missing or incorrect.


In general, this can occur when there are a genuine cross Site Request forgery, or when Django ' s CSRF mechanism have not bee n used correctly. For POST forms, you need to ensure:

Your Browser is accepting cookies.
The view function uses RequestContext for the template, instead of the Context.
In the template, there are a {% Csrf_token%} template tag inside each POST form that targets an internal URL.
If you is not using the Csrfviewmiddleware and then you must use Csrf_protect on any of the Csrf_token template tag, As well as those that accept the POST data.

You ' re seeing the "Help" section of the "This" page because you has DEBUG = True in your Django settings file. Change so to False, and only the initial error message would be displayed.

You can customize this page using the Csrf_failure_view setting.

Workaround: During the development process, you can temporarily comment on the settings.py

' Django.middleware.csrf.CsrfViewMiddleware ',



Because just contact with Python, Django, MySQL is also the first contact so may encounter is a small white problem, for their own remarks, may also help you.


Serial ing. You are welcome to add.

This article is from the "Wolf Soul" blog, please be sure to keep this source http://itwolf.blog.51cto.com/3286625/1611699

Django Python MYSQL Problem Collection

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.