当前位置:   article > 正文

python写网页前端页面源代码_Django认证系统实现的web网页实现代码

网站源码 python

结合数据库、ajax、js、Djangoform表单和认证系统的web网页

一:数据模块

扩展了Django中的user表,增加了自定义的字段

from django.db import models

from django.contrib.auth.models import AbstractUser

# Create your models here.

class UserInfo(AbstractUser):

phone = models.CharField(max_length=11)

gender = models.CharField(max_length=2)

二:路由系统

from django.conf.urls import url

from django.contrib import admin

from app01 import views

urlpatterns = [

url(r'^admin/', admin.site.urls),

url(r'^register/',views.register),

url(r'^login/',views.login_view),

url(r'^home/',views.home),

url(r'^logout/',views.logout_view),

url(r'^modify_pwd/',views.modify_pwd),

url(r'^$',views.home),

]

三:视图系统

from django.shortcuts import render, redirect

from django.contrib.auth.decorators import login_required

from django.http import JsonResponse

from django.contrib.auth import authenticate, login,logout

from app01 import forms

from app01.models import UserInfo

# Create your views here.

def register(request):

form_obj = forms.Reg_form()

if request.method == 'POST':

form_obj = forms.Reg_form(request.POST)

if form_obj.is_valid():

info_dic = form_obj.cleaned_data

sex_dic = {'1':'男','2':'女','3':'保密'}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/723160
推荐阅读
相关标签
  

闽ICP备14008679号