寫一個簡單的 django_post demo

1.新建一個django工程,其路由為下圖

2.要做的是一個 簡單的登錄請求,以表單形式提交,html 部分代碼如下

這里注意action指向的是路由的地址,index1后的views.login部分代碼如下

?

?這段代碼指的是,如果login接收到的請求是個post 然后就把傳入的用戶名 密碼輸出出來,因為我這個工程里面輸入server/index1/之后進入login,

但是這里進入的肯定不是一個post ,所以寫一個else直接進入到上文寫的那個html頁面中,在該頁面提交表單之后,輸出用戶名密碼,整體流程如下:

ps:如果要正確跳轉,這里先把setting中的csrf防御注釋,找到settings.py這個文件下的MIDLEWARE列表

?

?

轉載于:https://www.cnblogs.com/alantammm/p/10336441.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/278384.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/278384.shtml
英文地址,請注明出處:http://en.pswp.cn/news/278384.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

日志收集

2019獨角獸企業重金招聘Python工程師標準>>> ELK (ElasticSearch、Logstash、Kibana): https://my.oschina.net/itblog/blog/547250 轉載于:https://my.oschina.net/zfscofield/blog/1625703

autocopy2u_借助AutoCopy簡化Firefox中的文本復制和粘貼

autocopy2uLooking for an easy way to speed up copying and pasting in Firefox? Now you can reduce the amount of work that you have to do by half with AutoCopy. 是否在尋找一種簡便的方法來加快Firefox中的復制和粘貼? 現在,您可以使用自動復…

virtualenv模塊使用

開發多個應用: 如A需要jinja2.7開發;如B需要jinja2.6開發。或者C需要Python2.7開發,D需要Python3.5開發 那么解決上述問題就需要使用virtualenv這個模塊: 它的作用是:創建“隔離”環境,使項目擁有獨立的Pyt…

僵尸進程處理方式

Linux服務器上,多少會出現一些僵尸進程,下面介紹如何快速尋找和消滅這些僵尸進程的方法 首先,我們可以用top命令來查看服務器當前是否有僵尸進程,在下圖中可以看到僵尸進程數的提示,如果數字大于0,那么意味…

chromebook刷機_如何查看Chromebook的停產日期

chromebook刷機Google谷歌There comes a time in your Chromebook’s life when it no longer receives updates from Google. It’s inevitable and could be a lot sooner than you think. Here’s how to see your Chromebook’s scheduled end-of-life date. Chromebook一生…

C#將unix時間戳轉換成.net的DateTime類型的代碼

下面的內容是關于C#將unix時間戳轉換成.net的DateTime類型的內容。 DateTime epoch new DateTime(1970,1,1,0,0,0,0, DateTimeKind.Utc);DateTime myDate epoch.AddSeconds(1258598728).toLocalTime(); 轉載于:https://www.cnblogs.com/odsxe/p/10338494.html

【活動】AI人工智能技術沙龍 |杭州站

AI人工智能技術沙龍 |杭州站將于2018年3月3號在浙江杭州市文一西路1818-2號中國(杭州)人工智能小鎮舉辦由袋鼠云、七牛云及“因特鏈”社區的老師為大家帶來AI純技術干貨分享另有區塊鏈和AI人工智能技術融合技術主題1活動安排時間:2018年3月3號…

如何在Google文檔中的圖片周圍換行

If you want to insert an image or object into a document, it’s relatively simple. However, positioning and getting them to stay where you want can be frustrating. The wrap text feature in Google Docs makes all of this more manageable. 如果要將圖像或對象插…

mysql的left函數

1、LEFT()函數是一個字符串函數,它返回具有指定長度的字符串的左邊部分。 LEFT(Str,length); 接收兩個參數: str:一個字符串; length:想要截取的長度,是一個正整數; 2、示例: SELECT…

如何在Linux上使用history命令

Fatmawati Achmad Zaenuri/ShutterstockFatmawati Achmad Zaenuri / ShutterstockLinux’s shell saves a history of the commands you run, and you can search it to repeat commands you’ve run in the past. Once you understand the Linux history command and how to u…

mysql導入sqlserver數據庫表

原文:https://zhidao.baidu.com/question/1114325744502691499.html 在Navicat for MySQL 管理器中,創建目標數據庫(注意:因為是點對點的數據導入,要求sql server 中要導出的數據庫名稱和要導入到Mysql 中的數據庫的名字相同)點擊…

AppleScript

AppleScript 后綴名scpt do shell script "shell腳本"轉載于:https://www.cnblogs.com/yangwenhuan/p/10338580.html

ER圖三元聯系簡介

數據庫設計時,遇到三元聯系怎樣確定,下面做個簡單介紹。 一、確定聯系 三元聯系共 4 種情況: 1 : 1 : 11 : 1 : N1 : M : NM : N : P1 &#xff1…

mac自帶郵箱導出郵件_如何將電子郵件從Mac Mail導出到Notes應用程序

mac自帶郵箱導出郵件Khamosh PathakKhamosh PathakIf you use the Mail app regularly, you’re used to archiving or flagging emails for later. But what if you want to save a particular message for future reference in the Notes app? Well, there’s a work-around…

luogu P3380 【模板】二逼平衡樹(樹套樹)

恭喜你 以分塊的姿勢通過了此題 #include<cmath> #include<cstdio> #include<algorithm> #define inf (2147483647) using namespace std; const int N5e450; struct FK {int l,r;} K[500]; int n,m,T,sqr,ans,a[N],b[N],fa[N]; void work1(int l,int r,int …

Appium使用Python運行appium測試的實例

Appium使用Python運行appium測試的實例 一&#xff0e; Appium之介紹 https://testerhome.com/topics/8038 詳情參考-- https://testerhome.com/topics/8038 Appium是一個移動端的自動化框架&#xff0c;可用于測試原生應用&#xff0c;移動網頁應用和混合型應用&#xff0c;且…

ubuntu 任務欄監視器_從系統任務欄監視Google服務

ubuntu 任務欄監視器Are you looking for an app that sits in your System Tray and will notify you when you have new items in your Google accounts? Now you can easily monitor all of your favorite Google services with Googsystray. 您是否正在尋找一個位于系統任…

Java發送郵件(帶附件)

實現java發送郵件的過程大體有以下幾步&#xff1a; 準備一個properties文件&#xff0c;該文件中存放SMTP服務器地址等參數。利用properties創建一個Session對象利用Session創建Message對象&#xff0c;然后設置郵件主題和正文利用Transport對象發送郵件需要的jar有2個&#x…

google天氣預報接口_將天氣預報添加到谷歌瀏覽器

google天氣預報接口Are you looking for a quick and easy way to see your local weather forecast in Google Chrome? Then you will definitely want to take a good look at the AccuWeather Forecast extension. 您是否正在尋找一種快速簡便的方法來在Google Chrome瀏覽器…

hive中任意相鄰時間段數據獲取

通過sql語句獲取相鄰時段數據不比通過其它編程語言&#xff0c;因為sql里面沒有for循環&#xff0c;故在實現時需要增加一份副表數據&#xff0c;這里對該方法做一個記錄。背景&#xff1a;獲取2017年全年平臺用戶進出貴州省的次數&#xff08;分為進港次數和出港次數&#xff…