Django time and time difference of eight hours Mysql database problem solving

Recently developed on a project to record the user login time and login IP functionality by testing did not find any error, then Pidianpidian of migration update the database during the migration process I stumbled login time was two in the morning and more, but my test time is 10 o'clock in the morning, a full eight hours difference, look a bit blinded by the investigation area is no problem when Django time zone and Mysql, then create a new Django project to test:

Project Creation and app creation skip directly into the theme

  1. Showcase key elements of
    the database field
    Here Insert Picture Description
    views.py
    Here Insert Picture Description

  2. Call to see if the effect
    Here Insert Picture Description
    Here Insert Picture Description
    can be seen that the time difference of eight hours

  3. Modify some parameters of the configuration file settings.py

    LANGUAGE_CODE = 'zh-hans'
    
    TIME_ZONE = 'Asia/Shanghai'
    
    USE_TZ = False
    
  4. In the test, problem solving

    Here Insert Picture Description

Welcome attention of the same name micro-channel public number: Program ape Miscellany

Program ape Miscellany

Technology | exchange | welfare
Published 63 original articles · 87 won praise · views 40000 +

Guess you like

Origin blog.csdn.net/weixin_44110998/article/details/103615212
Recommended