项目名 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']}>