0831 SESAC(幼苗)第3期12日目
56436 ワード
value値としてロードされると、常に文字列としてロードされます.
文字の時が空白ならF
数字0はf/1はtを表す
「ファーストレディ」(これですか?)変数と文字列を配置できますが、変数を${}に配置できます.
ロングライブラリ管理者
root
qa2213886*
https://www.djangoproject.com/
https://docs.djangoproject.com/ko/3.2/topics/db/models/
モデルには、データベース、ユーザーというテーブルがあります.
from django.db import models
class Person(models.Model):
SHIRT_SIZES = (
('S', 'Small'),
('M', 'Medium'),
('L', 'Large'),
)
name = models.CharField(max_length=60)
shirt_size = models.CharField(max_length=1, choices=SHIRT_SIZES)
>>> p = Person(name="Fred Flintstone", shirt_size="L")
>>> p.save() //db에 삽입
>>> p.shirt_size
'L'
>>> p.get_shirt_size_display()
'Large'
{% for member in totoal_member %}{{member.userid}}
{% endfor %}
total memberのメンバーを一人ずつ呼んでください.
{% for member in total_member %}
아이디 : {{ member.userid }}<br>
이름 : {{ member.username }}<br>
<br>
<br>
<br>
{% endfor %}
User.objects.filter(username=req.POST.get('id'), password=req.POST.get('pw'));->idがそうであれば、pwにはこのようなメンバー(入力Inputウィンドウ)があり、//データベースの//ログインは成功します.
def logged(req):
logged_member = User.objects.filter(userid=req.POST.get('id'),password=req.POST.get('pw'))
if logged_member :
print("로그인성공")
else :
print("로그인실패")
実習
会員登録と登録機能を実現!
検察官になってこそ家に帰ることができる.
http://27.96.135.73:8000/yookeunbyul/join
http://27.96.135.73:8000/yookeunbyul/login
#member.urls.py
from django.urls import path
from . import views
urlpatterns = [
path('join', views.join),
path('joined', views.joined),
path('login', views.login ),
path('logged', views.logged ),
]
#member.views.py
from django.shortcuts import render
from .models import User #모델불러오려면 필수
# Create your views here.
def join ( req ) :
return render ( req, 'join.html' )
def joined ( req ) :
new_member = User( username = req.POST.get('name'), userid = req.POST.get('id'), password = req.POST.get('pwd'), gender = req.POST.get('gender') )
new_member.save() #데이터베이스에 저장
return render ( req, 'joined.html' )
def login( req ) :
return render( req, 'login.html' )
def logged( req ) :
logged_member = User.objects.filter(userid=req.POST.get('id'), password=req.POST.get('pwd')) #필터링
if logged_member :
print("로그인 성공")
return render( req, 'logged.html' )
else :
print("로그인 실패")
return render( req, 'unlogged.html' )
#join.html
<html>
<head>
<title>회원가입</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<form action="http://27.96.135.73:8000/yookeunbyul/joined" method="post">
{% csrf_token %}
<div class="input-group flex-nowrap my-3">
<div class="input-group-prepend">
<span class="input-group-text" id="addon-wrapping">name</span>
</div>
<input type="text" class="form-control" placeholder="Username" name='name'>
</div>
<div class="input-group flex-nowrap my-3">
<div class="input-group-prepend">
<span class="input-group-text" id="addon-wrapping">id</span>
</div>
<input type="text" class="form-control" placeholder="Userid" name='id'>
</div>
<div class="input-group flex-nowrap my-3">
<div class="input-group-prepend">
<span class="input-group-text" id="addon-wrapping">password</span>
</div>
<input type="text" class="form-control" placeholder="Userpwd" name='pwd'>
</div>
<div class="input-group my-3">
<div class="input-group-prepend">
<label class="input-group-text" for="inputGroupSelect01">gender</label>
</div>
<select class="custom-select" id="inputGroupSelect01" name='gender'>
<option selected>gender</option>
<option value="M">남성</option>
<option value="W">여성</option>
</select>
</div>
<button type="submit" class="btn btn-primary my-3">회원가입</button>
</form>
</div>
</body>
</html>
#joined.html
<html>
<head>
<title>회원가입 성공</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<div class="text-center my-3">회원가입을 축하합니다</div>
<div class="text-center">
<a href="http://27.96.135.73:8000/yookeunbyul/login">
<button type="button" class="btn btn-warning">로그인하러가기</button>
</a>
</div>
</div>
</body>
</html>
#login.html
<html>
<head>
<title>로그인</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<form action="http://27.96.135.73:8000/yookeunbyul/logged" method="post">
{% csrf_token %}
<div class="input-group flex-nowrap my-3">
<div class="input-group-prepend">
<span class="input-group-text" id="addon-wrapping">id</span>
</div>
<input type="text" class="form-control" placeholder="Userid" name='id'>
</div>
<div class="input-group flex-nowrap my-3">
<div class="input-group-prepend">
<span class="input-group-text" id="addon-wrapping">password</span>
</div>
<input type="text" class="form-control" placeholder="Userpwd" name='pwd'>
</div>
<button type="submit" class="btn btn-primary">로그인</button>
</form>
</div>
</body>
</html>
#logged.html
<html>
<head>
<title>로그인 성공</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
</head>
<body>
<div class="container my-3">
<div class="text-center">로그인을 성공하였습니다</div>
</div>
</body>
</html>
#unlogged.html
<html>
<head>
<title>로그인 실패</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
</head>
<body>
<div class="container my-3">
<div class="text-center">로그인을 실패하였습니다</div>
</div>
</body>
</html>
Reference
この問題について(0831 SESAC(幼苗)第3期12日目), 我々は、より多くの情報をここで見つけました https://velog.io/@gordthemun/0831-SSAC싹-3기-12일차テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol