zoukankan      html  css  js  c++  java
  • Django 简单用户注册

    项目名 macboy

    app名 t1

    1.项目macboy urls.py

    from django.conf.urls import url, include

    urlpatterns = [ url(r'^t1/', include("t1.urls")), ]

    2.app t1下的路由系统urls.py

    from django.conf.urls import url
    
    from t1.views import register
    
    urlpatterns = [
        url(r'^register.html$', register, name="register"),
    ]

    3.app t1下面的视图views.py

    from django.shortcuts import render, HttpResponse, redirect
    
    def register(request):
        print(request.GET)
        user_info = request.POST
        # print(user_info["username"])
        # print(user_info.get("password"))
        return render(request, "t1/register.html")

    4.templates 下的 t1/register.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        {% load staticfiles %}
        <script src="{% static 'plugins/jquery.min.js' %}"></script>
    
    </head>
    <body>
         <form action="{% url 'register' %}" method="post">
             用户名:<input type="text" name="username"><p></p>
             密  码:<input type="password" name="password"><p></p>
             <input type="submit" value="submit" >
         </form>
        <script>
            $(":submit").css("color","blue");
        </script>
    </body>
    </html>

    5.后台显示:

    <QueryDict: {'password': ['zhangsan'], 'username': ['zhangsan']}>
  • 相关阅读:
    不能在注册表中识别出来python时的解决方法
    Biopython
    Biopython
    生信相关网站
    linux下的查找命令
    class
    不同版本的Eclipse安装SVN插件
    【如何快速的开发一个完整的iOS直播app】(原理篇)
    iOS 直播
    Ios-视频直播-知识点汇总-持续更新
  • 原文地址:https://www.cnblogs.com/icemonkey/p/10506173.html
Copyright © 2011-2022 走看看