简体   繁体   中英

How can I save form's value into mysql database table? (post method)

mysql> describe posts;
+----------+---------------+------+-----+---------+-------+
| Field    | Type          | Null | Key | Default | Extra |
+----------+---------------+------+-----+---------+-------+
| id       | int(11)       | NO   | PRI | NULL    |       |
| title    | varchar(300)  | NO   |     | NULL    |       |
| content  | varchar(1000) | NO   |     | NULL    |       |
| created  | date          | YES  |     | NULL    |       |
| modified | date          | YES  |     | NULL    |       |
+----------+---------------+------+-----+---------+-------+
5 rows in set (0.01 sec)

How would i create form in template? How would i access the value of that form in views.py and save into database table? I have also read this=> https://docs.djangoproject.com/en/dev/topics/forms/ but could not understand how to implement it.

django书中的第7章解决了您的问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM