赞
踩
结合数据库、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':'保密'}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。