欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Django實(shí)現(xiàn)前后端登錄

 更新時(shí)間:2021年04月30日 15:17:58   作者:gexzygg  
這篇文章主要介紹了Django實(shí)現(xiàn)前后端登錄的示例,幫助大家更好的理解和學(xué)習(xí)使用Django,感興趣的朋友可以了解下

前端登錄

1. login.vue

<template>
    <div class="sign">
    <div class="logo"><a href="/" rel="external nofollow" ><img src="/static/image/nav-logo.png" alt="Logo"></a></div>
    <div class="main">


<h4 class="title">
  <div class="normal-title">
    <a class="active" href="/login" rel="external nofollow" >登錄</a>
    <b>·</b>
    <a id="js-sign-up-btn" class="" href="/register" rel="external nofollow" >注冊(cè)</a>
  </div>
</h4>
<div class="js-sign-in-container">
  <form id="new_session" action="" method="post">
      <div class="input-prepend restyle js-normal">
        <input placeholder="手機(jī)號(hào)或郵箱" type="text" name="session[email_or_mobile_number]" id="session_email_or_mobile_number">
        <i class="iconfont ic-user"></i>
      </div>
    <!-- 海外登錄登錄名輸入框 -->

    <div class="input-prepend">
      <input placeholder="密碼" type="password" name="password" id="session_password">
      <i class="iconfont ic-password"></i>
    </div>
    <div class="remember-btn">
      <input type="checkbox" value="true" checked="checked" name="remember_me" id="session_remember_me"><span>記住我</span>
    </div>
    <div class="forget-btn">
      <a class="" data-toggle="dropdown" href="">登錄遇到問題?</a>
    </div>
    <button class="sign-in-button" id="sign-in-form-submit-btn" type="button">
      <span id="sign-in-loading"></span>
      登錄
    </button>
</form>
  <!-- 更多登錄方式 -->
  <div class="more-sign">
    <h6>社交帳號(hào)登錄</h6>
    <ul>
  <li id="weibo-link-wrap" class="">
    <a class="weibo" id="weibo-link">
      <i class="iconfont ic-weibo"></i>
    </a>
  </li>
  <li><a id="weixin" class="weixin" target="_blank" href=""><i class=" rel="external nofollow"  rel="external nofollow" iconfont ic-wechat"></i></a></li>
  <li><a id="qq" class="qq" target="_blank" href=""><i class=" rel="external nofollow"  rel="external nofollow" iconfont ic-qq_connect"></i></a></li>
</ul>
  </div>
</div>

    </div>
  </div>
</template>

<script>
    export default {
        name: "Login"
    }
</script>

<style scoped>
input{
  outline: none;
}
*, :after, :before {
    box-sizing: border-box;
}
.sign {
	height: 100%;
	min-height: 750px;
	text-align: center;
	font-size: 14px;
	background-color: #f1f1f1
}

.sign:before {
	content: "";
	display: inline-block;
	height: 85%;
	vertical-align: middle
}

.sign .disable,.sign .disable-gray {
	opacity: .5;
	pointer-events: none
}

.sign .disable-gray {
	background-color: #969696
}

.sign .tooltip-error {
	font-size: 14px;
	line-height: 25px;
	white-space: nowrap;
	background: none
}

.sign .tooltip-error .tooltip-inner {
	max-width: 280px;
	color: #333;
	border: 1px solid #ea6f5a;
	background-color: #fff
}

.sign .tooltip-error .tooltip-inner i {
	position: static;
	margin-right: 5px;
	font-size: 20px;
	color: #ea6f5a;
	vertical-align: middle
}

.sign .tooltip-error .tooltip-inner span {
	vertical-align: middle;
	display: inline-block;
	white-space: normal;
	max-width: 230px
}

.sign .tooltip-error.right .tooltip-arrow-border {
	border-right-color: #ea6f5a
}

.sign .tooltip-error.right .tooltip-arrow-bg {
	left: 2px;
	border-right-color: #fff
}

.sign .slide-error {
	position: relative;
	padding: 10px 0;
	border: 1px solid #c8c8c8;
	border-radius: 4px
}

.sign .slide-error i {
	position: static!important;
	margin-right: 10px;
	color: #ea6f5a!important;
	vertical-align: middle
}

.sign .slide-error span {
	font-size: 15px;
	vertical-align: middle
}

.sign .slide-error div {
	margin-top: 10px;
	font-size: 13px
}

.sign .slide-error a {
	color: #3194d0
}

.sign .js-sign-up-forbidden {
	color: #999;
	padding: 80px 0 100px
}

.sign .js-sign-up-container .slide-error {
	border-bottom: none;
	border-radius: 0
}

.sign .logo {
	position: absolute;
	top: 56px;
	margin-left: 50px
}

.sign .logo img {
	width: 100px
}

.sign .main {
	width: 400px;
	margin: 60px auto 0;
	padding: 50px 50px 30px;
	background-color: #fff;
	border-radius: 4px;
	box-shadow: 0 0 8px rgba(0,0,0,.1);
	vertical-align: middle;
	display: inline-block
}

.sign .reset-title,.sign .title {
	margin: 0 auto 50px;
	padding: 10px;
	font-weight: 400;
	color: #969696
}

.sign .reset-title a,.sign .title a {
	padding: 10px;
	color: #969696
}

.sign .reset-title a:hover,.sign .title a:hover {
	border-bottom: 2px solid #ea6f5a
}

.sign .reset-title .active,.sign .title .active {
	font-weight: 700;
	color: #ea6f5a;
	border-bottom: 2px solid #ea6f5a
}

.sign .reset-title b,.sign .title b {
	padding: 10px
}

.sign .reset-title {
	color: #333;
	font-weight: 700
}

.sign form {
	margin-bottom: 30px
}

.sign form .input-prepend {
	position: relative;
	width: 100%
}

.sign form .input-prepend input {
	width: 100%;
	height: 50px;
	margin-bottom: 0;
	padding: 4px 12px 4px 35px;
	border: 1px solid #c8c8c8;
	border-radius: 0 0 4px 4px;
	background-color: hsla(0,0%,71%,.1);
	vertical-align: middle
}

.sign form .input-prepend i {
	position: absolute;
	top: 14px;
	left: 10px;
	font-size: 18px;
	color: #969696
}

.sign form .input-prepend span {
	color: #333
}

.sign form .input-prepend .ic-show {
	top: 18px;
	left: auto;
	right: 8px;
	font-size: 12px
}

.sign form .geetest-placeholder {
	height: 44px;
	border-radius: 4px;
	background-color: hsla(0,0%,71%,.1);
	text-align: center;
	line-height: 44px;
	font-size: 14px;
	color: #999
}

.sign form .restyle {
	margin-bottom: 0
}

.sign form .restyle input {
	border-bottom: none;
	border-radius: 4px 4px 0 0
}

.sign form .no-radius input {
	border-radius: 0
}

.sign form .slide-security-placeholder {
	height: 32px;
	background-color: hsla(0,0%,71%,.1);
	border-radius: 4px
}

.sign form .slide-security-placeholder p {
	padding-top: 7px;
	color: #999;
	margin-right: -7px
}

.sign .overseas-btn {
	font-size: 14px;
	color: #999
}

.sign .overseas-btn:hover {
	color: #2f2f2f
}

.sign .remember-btn {
	float: left;
	margin: 15px 0
}

.sign .remember-btn span {
	margin-left: 5px;
	font-size: 15px;
	color: #969696;
	vertical-align: middle
}

.sign .forget-btn {
	float: right;
	position: relative;
	margin: 15px 0;
	font-size: 14px
}

.sign .forget-btn a {
	color: #999
}

.sign .forget-btn a:hover {
	color: #333
}

.sign .forget-btn .dropdown-menu {
	top: 20px;
	left: auto;
	right: 0;
	border-radius: 4px
}

.sign .forget-btn .dropdown-menu a {
	padding: 10px 20px;
	color: #333
}

.sign #sign-in-loading {
	position: relative;
	width: 20px;
	height: 20px;
	vertical-align: middle;
	margin-top: -4px;
	margin-right: 2px;
	display: none
}

.sign #sign-in-loading:after {
	content: "";
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	background-color: transparent
}

.sign #sign-in-loading:before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 20px;
	height: 20px;
	margin: -10px 0 0 -10px;
	border-radius: 10px;
	border: 2px solid #fff;
	border-bottom-color: transparent;
	vertical-align: middle;
	-webkit-animation: rolling .8s infinite linear;
	animation: rolling .8s infinite linear;
	z-index: 1
}

.sign .sign-in-button,.sign .sign-up-button {
	margin-top: 20px;
	width: 100%;
	padding: 9px 18px;
	font-size: 18px;
	border: none;
	border-radius: 25px;
	color: #fff;
	background: #42c02e;
	cursor: pointer;
	outline: none;
	display: block;
	clear: both
}

.sign .sign-in-button:hover,.sign .sign-up-button:hover {
	background: #3db922
}

.sign .sign-in-button {
	background: #3194d0
}

.sign .sign-in-button:hover {
	background: #187cb7
}

.sign .btn-in-resend,.sign .btn-up-resend {
	position: absolute;
	top: 7px;
	right: 7px;
	width: 100px;
	height: 36px;
	font-size: 13px;
	color: #fff;
	background-color: #42c02e;
	border-radius: 20px;
	line-height: 36px
}

.sign .btn-in-resend {
	background-color: #3194d0
}

.sign .sign-up-msg {
	margin: 10px 0;
	padding: 0;
	text-align: center;
	font-size: 12px;
	line-height: 20px;
	color: #969696
}

.sign .sign-up-msg a,.sign .sign-up-msg a:hover {
	color: #3194d0
}

.sign .overseas input {
	padding-left: 110px!important
}

.sign .overseas .overseas-number {
	position: absolute;
	top: 0;
	left: 0;
	width: 100px;
	height: 50px;
	font-size: 18px;
	color: #969696;
	border-right: 1px solid #c8c8c8
}

.sign .overseas .overseas-number span {
	margin-top: 17px;
	padding-left: 35px;
	text-align: left;
	font-size: 14px;
	display: block
}

.sign .overseas .dropdown-menu {
	width: 100%;
	max-height: 285px;
	font-size: 14px;
	border-radius: 0 0 4px 4px;
	overflow-y: auto
}

.sign .overseas .dropdown-menu li .nation-code {
	width: 65px;
	display: inline-block
}

.sign .overseas .dropdown-menu li a {
	padding: 6px 20px;
	font-size: 14px;
	line-height: 20px
}

.sign .overseas .dropdown-menu li a::hover {
	color: #fff;
	background-color: #f5f5f5
}

.sign .more-sign {
	margin-top: 50px
}

.sign .more-sign h6 {
	position: relative;
	margin: 0 0 10px;
	font-size: 12px;
	color: #b5b5b5
}

.sign .more-sign h6:before {
	left: 30px
}

.sign .more-sign h6:after,.sign .more-sign h6:before {
	content: "";
	border-top: 1px solid #b5b5b5;
	display: block;
	position: absolute;
	width: 60px;
	top: 5px
}

.sign .more-sign h6:after {
	right: 30px
}

.sign .more-sign ul {
	margin-bottom: 10px;
	list-style: none
}

.sign .more-sign ul li {
	margin: 0 5px;
	display: inline-block
}

.sign .more-sign ul a {
	width: 50px;
	height: 50px;
	line-height: 50px;
	display: block
}

.sign .more-sign ul i {
	font-size: 28px
}

.sign .more-sign .ic-weibo {
	color: #e05244
}

.sign .more-sign .ic-wechat {
	color: #00bb29
}

.sign .more-sign .ic-qq_connect {
	color: #498ad5
}

.sign .more-sign .ic-douban {
	color: #00820f
}

.sign .more-sign .ic-more {
	color: #999
}

.sign .more-sign .weibo-loading {
	pointer-events: none;
	cursor: pointer;
	position: relative
}

.sign .more-sign .weibo-loading:after {
	content: "";
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	background-color: #fff
}

body.reader-night-mode .sign .more-sign .weibo-loading:after {
	background-color: #3f3f3f
}

.sign .more-sign .weibo-loading:before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 20px;
	height: 20px;
	margin: -10px 0 0 -10px;
	border-radius: 10px;
	border: 2px solid #e05244;
	border-bottom-color: transparent;
	vertical-align: middle;
	-webkit-animation: rolling .8s infinite linear;
	animation: rolling .8s infinite linear;
	z-index: 1
}

@keyframes rolling {
	0% {
		-webkit-transform: rotate(0deg);
		transform: rotate(0deg)
	}

	to {
		-webkit-transform: rotate(1turn);
		transform: rotate(1turn)
	}
}

@-webkit-keyframes rolling {
	0% {
		-webkit-transform: rotate(0deg)
	}

	to {
		-webkit-transform: rotate(1turn)
	}
}

.sign .reset-password-input {
	border-radius: 4px!important
}

.sign .return {
	margin-left: -8px;
	color: #969696
}

.sign .return:hover {
	color: #333
}

.sign .return i {
	margin-right: 5px
}

.sign .icheckbox_square-green {
	display: inline-block;
	*display: inline;
	vertical-align: middle;
	margin: 0;
	padding: 0;
	width: 18px;
	height: 18px;
	background: url(/static/image/green.png) no-repeat;
	border: none;
	cursor: pointer;
	background-position: 0 0
}

.sign .icheckbox_square-green.hover {
	background-position: -20px 0
}

.sign .icheckbox_square-green.checked {
	background-position: -40px 0
}

.sign .icheckbox_square-green.disabled {
	background-position: -60px 0;
	cursor: default
}

.sign .icheckbox_square-green.checked.disabled {
	background-position: -80px 0
}


.geetest_panel_box>* {
	box-sizing: content-box
}

@media (max-width:768px) {
	body {
		min-width: 0
	}

	.sign {
		height: auto;
		min-height: 0;
		background-color: transparent
	}

	.sign .logo {
		display: none
	}

	.sign .main {
		position: absolute;
		left: 50%;
		margin: 0 0 0 -200px;
		box-shadow: none
	}
}
</style>

2.設(shè)置路由

router/index.JS

import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/components/Home'
import Login from '@/components/Login'
import Register from "../src/components/Register";
import QQLoginIndex from '@/components/OOLoginIndex'


Vue.vue(Router)

export default new Router({
  mode:'history',
  routes:[
    {
      path:'/',
      component:Home
    },
    {
      path:'/login',
      component: Login
    },
    {
      path:'/register',
      component: Register
    },
    {
      path:'/oauth_callback.html',
      component: QQLoginIndex
    }
  ]
})

3.登錄標(biāo)簽設(shè)置

header.vue

將a 標(biāo)簽設(shè)置為 router-link(站外鏈接調(diào)整為站內(nèi)鏈接)

<router-link class="btn log-in" id="sign_in" to="/login">登錄</router-link>

后端登錄

2.1 創(chuàng)建一個(gè)用戶表

虛擬環(huán)境下

cd renranapi/renranapi/apps
python ../../manage.py startapp users

2.2 Settings/dev/py 新增配置

INSTALLED_APPS = [
  
    #以下為第三方軟件
    'corsheaders',
    'users'
]

2.3 運(yùn)行時(shí)報(bào)錯(cuò)修& 改配置環(huán)境路徑

報(bào)錯(cuò)

修改配置環(huán)境路徑

settings.dev.py

修改配置環(huán)境路徑
settings.dev.py

2.4 創(chuàng)建用戶模型類

Renranapi/apps/users/migrations/models.py

from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
class User(AbstractUser):
    """用戶模型類"""
    mobile = models.CharField(max_length=15, null=True,blank=True, unique=True, help_text="手機(jī)號(hào)碼",verbose_name="手機(jī)號(hào)碼")
    wxchat = models.CharField(max_length=100, null=True, blank=True, unique=True, help_text="微信賬號(hào)",verbose_name="微信賬號(hào)")
    alipay = models.CharField(max_length=100, null=True, blank=True, unique=True, help_text="支付寶賬號(hào)",verbose_name="支付寶賬號(hào)")
    qq_number = models.CharField(max_length=11, null=True, blank=True, unique=True, help_text="QQ號(hào)",verbose_name="QQ號(hào)")
    # 保存文件的子目錄
    avatar = models.ImageField(upload_to="avatar", null=True,blank=True, default=None, verbose_name="頭像")

    class Meta:
        db_table = "rr_users"
        verbose_name = "用戶信息"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.username

2.5 配置

settings/dev.py

AUTH_USER_MODEL = 'users.User'

2.6 數(shù)據(jù)庫(kù)遷移

python ../../manage.py makemigrations
python ../../ manage.py migrate

設(shè)置 mysql

admin 配置

創(chuàng)建超級(jí)管理員

此時(shí)后臺(tái)數(shù)據(jù)庫(kù)

進(jìn)入http://127.0.0.1:8000/admin/
root 用戶登錄:root 密碼 123

以上就是Django實(shí)現(xiàn)前后端登錄的詳細(xì)內(nèi)容,更多關(guān)于Django 前后端登錄的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 個(gè)人微信公眾號(hào)接入ChatGPT的教程分享

    個(gè)人微信公眾號(hào)接入ChatGPT的教程分享

    這篇文章主要為大家詳細(xì)介紹了如何為個(gè)人微信公眾號(hào)接入ChatGPT,文中的實(shí)現(xiàn)步驟講解詳細(xì),具有一定的學(xué)習(xí)價(jià)值,感興趣的小伙伴可以了解一下
    2023-05-05
  • python中g(shù)event庫(kù)的用法詳情

    python中g(shù)event庫(kù)的用法詳情

    這篇文章主要介紹了python中g(shù)event庫(kù)的用法詳情,Greenlet全部運(yùn)行在主程序操作系統(tǒng)的過程中,但是它們是協(xié)作調(diào)度的,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值
    2022-07-07
  • python如何派生內(nèi)置不可變類型并修改實(shí)例化行為

    python如何派生內(nèi)置不可變類型并修改實(shí)例化行為

    這篇文章主要為大家詳細(xì)介紹了python如何派生內(nèi)置不可變類型并修改實(shí)例化行為,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-03-03
  • python pandas模塊進(jìn)行數(shù)據(jù)分析

    python pandas模塊進(jìn)行數(shù)據(jù)分析

    Python的Pandas模塊是一個(gè)強(qiáng)大的數(shù)據(jù)處理工具,可以用來讀取、處理和分析各種數(shù)據(jù),本文主要介紹了python pandas模塊進(jìn)行數(shù)據(jù)分析,具有一定的參考價(jià)值,感興趣的可以了解一下
    2024-01-01
  • Python異常處理try語句應(yīng)用技巧實(shí)例探究

    Python異常處理try語句應(yīng)用技巧實(shí)例探究

    異常處理在Python中是至關(guān)重要的,try-except是用于捕獲和處理異常的核心機(jī)制之一,本文就帶大家深入了解如何使用try-except,處理各種異常情況
    2024-01-01
  • flask數(shù)據(jù)庫(kù)序列化操作實(shí)例探究

    flask數(shù)據(jù)庫(kù)序列化操作實(shí)例探究

    這篇文章主要為大家介紹了flask數(shù)據(jù)庫(kù)序列化操作實(shí)例探究,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2024-01-01
  • python判斷變量是否是None的三種寫法總結(jié)

    python判斷變量是否是None的三種寫法總結(jié)

    代碼中經(jīng)常會(huì)有變量是否為None的判斷,這篇文章給大家總結(jié)了三種判斷變量是否是none的寫法,文中通過代碼示例介紹的非常詳細(xì),需要的朋友可以參考下
    2023-12-12
  • Python日志器使用方法及原理解析

    Python日志器使用方法及原理解析

    這篇文章主要介紹了Python日志器使用方法及原理解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-09-09
  • Python學(xué)習(xí)筆記之Zip和Enumerate用法實(shí)例分析

    Python學(xué)習(xí)筆記之Zip和Enumerate用法實(shí)例分析

    這篇文章主要介紹了Python學(xué)習(xí)筆記之Zip和Enumerate用法,結(jié)合實(shí)例形式分析了Zip和Enumerate的功能、用法及相關(guān)操作注意事項(xiàng),需要的朋友可以參考下
    2019-08-08
  • pyinstaller執(zhí)行報(bào)錯(cuò)的問題解決

    pyinstaller執(zhí)行報(bào)錯(cuò)的問題解決

    有時(shí)候,PyInstaller可能無法正確識(shí)別和打包所有的依賴項(xiàng),導(dǎo)致名稱錯(cuò)誤,本文主要介紹了pyinstaller執(zhí)行報(bào)錯(cuò)的解決方案,感興趣的可以了解一下
    2023-11-11

最新評(píng)論