当前位置:网站首页>[introduction to Django] 11 web page associated MySQL single field table (add, modify, delete)

[introduction to Django] 11 web page associated MySQL single field table (add, modify, delete)

2022-07-06 03:50:00 navii

Design Bootstrap Front page ( increase )

  • from v3 Chinese document —— Components —— panel , Copy wheel :
  • from v3 Chinese document —— overall situation CSS style —— Forms , Copy wheel :

relation Mysql( increase )

  • html code , Add a statement to the form ,method = "post"
    Don't write action ="" when , Send to the page itself by default POST
  • views.py code ,GET Open the page when ;POST To modify Mysql And jump to the query page

relation Mysql( Delete )

  • html code ,“ Delete ” Button jumps to band nid Numbered delete page
  • views.py code , from GET request get To nid, modify Mysql And jump to the query page

relation Mysql( Change ), It's a little complicated

  • Design Bootstrap Front page ( Change )—— And “ page ( increase )” Almost unanimously
  • urls.py code , Use regular , take nid Put it in the middle of the link
  • html( check ) code ,“ edit ” Button to jump to this line id In the edit page
  • views.py code , Receive GET When asked , Get... Directly nid, Get relevant data from the database , Pass on to html
  • views.py code , Receive POST When asked , modify Mysql
  • html( Change ) code , obtain nid Relevant database data , On display in form Inside




source :BV1NL41157 Wu Peiqi 《2022 B Station the most detailed django3 course (django From introduction to practice )》P24-P28

原网站

版权声明
本文为[navii]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202132304446771.html