8000 refine the sign app · python012/guest@9a1ace6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9a1ace6

Browse files
committed
refine the sign app
1 parent 7f61a04 commit 9a1ace6

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ A Web project based on Django, used for Web programming, Web API testing etc.
44

55
Installed app:
66

7-
- sign
7+
- sign
8+
9+
Commands:
10+
11+
- `python3 manage.py runserver` or `python3 manage.py runserver 127.0.0.1:8001` to launch the site.

guest/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@
2020
urlpatterns = [
2121
url(r'^admin/', admin.site.urls),
2222
url(r'^index/$', views.index),
23+
url(r'^login_action/$', views.login_action),
2324
]

sign/templates/index.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
<title>Django Page</title>
88
</head>
99
<body>
10-
<h1>Great Django Page!</h1>
10+
<h1>发布会管理</h1>
11+
<form action="/login_action/" method="POST">
12+
<input type="text" name="username" placeholder="username">
13+
<br>
14+
<input type="password" name="password" placeholder="password">
15+
<br>
16+
{{ error_message }}
17+
<br>
18+
<button id="btn" type="submit">登录</button>
19+
{% csrf_token %}
20+
</form>
1121
</body>
1222
</html>

sign/views.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
from django.shortcuts import render
22
from django.http import HttpResponse
33

4+
45
# Create your views here.
56
def index(request):
67
# return HttpResponse("Hello Django!")
78
return render(request, "index.html")
9+
10+
11+
def login_action(request):
12+
if request.method == 'POST':
13+
username = request.POST.get('username', '')
14+
password = request.POST.get('password', '')
15+
16+
if username == 'admin' and password == 'admin123':
17+
return HttpResponse('Login success!')
18+
else:
19+
return render(request, 'index.html', {'error_message': 'username or password is not correct!'})

0 commit comments

Comments
 (0)
0