Add a few lines MySQL User information
insert into app01_userinfo(name,password,age,account,create_time,gender,depart_id)values(" Liu Dong ","123",23,100.68,"2010-11-11",1,1);
insert into app01_userinfo(name,password,age,account,create_time,gender,depart_id)values(" Han Chao ","666",23,100.68,"2001-01-11",2,1);
insert into app01_userinfo(name,password,age,account,create_time,gender,depart_id)values(" Zhu hufei ","123",23,9900.68,"2021-05-11",1,3);
With python Syntax get database value
- Date to string , Use strftime(), The meaning of parameters in brackets can be Baidu
- Outreach field (ForeignKey),Django Support to return an object
for example depart.id = depart_id;depart.title = depart_id stay Department Corresponding to title - The number defined by the array ,Django Provide functions ,obj.get_???._display(), Get the original value
With html Template syntax gets database values
Be careful : Template syntax should never be bracketed (Django Will be backstage at the right time , Automatically bracketed )
- Pay attention to the template syntax , Writing method of date to string
- get_gender_display Don't put parentheses after
source :BV1NL41157 Wu Peiqi 《2022 B Station the most detailed django3 course (django From introduction to practice )》P30