# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.http import HttpResponse
from django.shortcuts import render
from .models import *
# Create your views here.
def index_view(request):
m = request.method
if m=='GET':
return render(request,'register.html')
else:
# 获取请求参数
uname=request.POST.get('uname','')
pwd=request.POST.get('pwd','')
# 判断
if uname and pwd:
# 创建模型对象
stu=Student(sname=uname,spwd=pwd)
# 插入数据库
stu.save()
return HttpResponse('注册成功')
return HttpResponse('注册失败')
Python Django 注册功能代码实现
原创a772304419 ©著作权
©著作权归作者所有:来自51CTO博客作者a772304419的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
如何基于Django中的WebSockets和异步视图来实现实时通信功能
探讨如何利用Django中的WebSockets和异步视图来实现实时通信功能。
数据 WebSockets Django 异步视图 实时通信 -
如何实现Java结合Python写代码
实现Java结合Python写代码
Java Python java -
注册功能代码实现--Django播客系统(十)
注册功能代码实现–Django播客系统(十)文章目录注册功能代码实现--Django播客系统(十)注册功
react python django ios css -
Python实战项目练习-Django商城项目之注册功能实现
项目的前端页面使用vue来实现局部刷新,通过数据的双向绑定实现与用户的交互,下面来看一下需求,在用户输入
python 软件测试 程序员 接口测试 自动化测试 -
django 快速实现注册
django 快速实现注册功能
django html 数据库 -
用户注册功能实现及代码优化案例
用户注册实现及代码优化的案例
postman 测试工具 服务器 java 前端