Commit d873dcdf authored by kaiwit.th.63's avatar kaiwit.th.63

login and register

parent fe0f3615
No preview for this file type
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pos food</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Prompt&display=swap" rel="stylesheet">
<script src="https://unpkg.com/flowbite@1.5.3/dist/datepicker.js"></script>
<style>
body{
font-family: 'Prompt', sans-serif;
}
</style>
</head>
<body >
<!-- component -->
<section class="h-screen">
<div class="container px-6 py-12 h-full">
<div class="flex justify-center items-center flex-wrap h-full g-6 text-gray-800">
<div class="md:w-8/12 lg:w-6/12 mb-12 md:mb-0">
<img
src="https://mdbcdn.b-cdn.net/img/Photos/new-templates/bootstrap-login-form/draw2.svg"
class="w-full"
alt="Phone image"
/>
</div>
<div class="md:w-8/12 lg:w-5/12 lg:ml-20">
<form class="space-y-4 md:space-y-6" action="/userlogin" method="post">
{% csrf_token %}
<!-- Email input -->
<div class="mb-6">
<input
for="username" type="text" id="username" name="username"
class="form-control block w-full px-4 py-2 text-xl font-normal text-gray-700 bg-white bg-clip-padding border border-solid border-gray-300 rounded transition ease-in-out m-0 focus:text-gray-700 focus:bg-white focus:border-blue-600 focus:outline-none"
placeholder=""
/>
</div>
<!-- Password input -->
<div class="mb-6">
<input
for="password" type="password" id="password" name="password"
class="form-control block w-full px-4 py-2 text-xl font-normal text-gray-700 bg-white bg-clip-padding border border-solid border-gray-300 rounded transition ease-in-out m-0 focus:text-gray-700 focus:bg-white focus:border-blue-600 focus:outline-none"
placeholder="Password"
/>
</div>
<div class="flex justify-between items-center mb-6">
<div class="form-group form-check">
<input
type="checkbox"
class="form-check-input appearance-none h-4 w-4 border border-gray-300 rounded-sm bg-white checked:bg-blue-600 checked:border-blue-600 focus:outline-none transition duration-200 mt-1 align-top bg-no-repeat bg-center bg-contain float-left mr-2 cursor-pointer"
id="exampleCheck3"
checked
/>
<label class="form-check-label inline-block text-gray-800" for="exampleCheck2"
>Remember me</label
>
</div>
<a
href="#!"
class="text-blue-600 hover:text-blue-700 focus:text-blue-700 active:text-blue-800 duration-200 transition ease-in-out"
>Forgot password?</a
>
</div>
<!-- Submit button -->
<button
type="submit"
class="inline-block px-7 py-3 bg-blue-600 text-white font-medium text-sm leading-snug uppercase rounded shadow-md hover:bg-blue-700 hover:shadow-lg focus:bg-blue-700 focus:shadow-lg focus:outline-none focus:ring-0 active:bg-blue-800 active:shadow-lg transition duration-150 ease-in-out w-full"
data-mdb-ripple="true"
data-mdb-ripple-color="light"
>
Sign in
</button>
<div
class="flex items-center my-4 before:flex-1 before:border-t before:border-gray-300 before:mt-0.5 after:flex-1 after:border-t after:border-gray-300 after:mt-0.5"
>
<p class="text-center font-semibold mx-4 mb-0">OR</p>
</div>
<a
class="px-7 py-3 text-white font-medium text-sm leading-snug uppercase rounded shadow-md hover:shadow-lg focus:shadow-lg focus:outline-none focus:ring-0 active:shadow-lg transition duration-150 ease-in-out w-full flex justify-center items-center mb-3"
style="background-color: #3b5998"
href="#!"
role="button"
data-mdb-ripple="true"
data-mdb-ripple-color="light"
>
<!-- Facebook -->
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 320 512"
class="w-3.5 h-3.5 mr-2"
>
<path
fill="currentColor"
d="M279.14 288l14.22-92.66h-88.91v-60.13c0-25.35 12.42-50.06 52.24-50.06h40.42V6.26S260.43 0 225.36 0c-73.22 0-121.08 44.38-121.08 124.72v70.62H22.89V288h81.39v224h100.17V288z"
/></svg>Continue with Facebook
</a>
<a
class="px-7 py-3 text-white font-medium text-sm leading-snug uppercase rounded shadow-md hover:shadow-lg focus:shadow-lg focus:outline-none focus:ring-0 active:shadow-lg transition duration-150 ease-in-out w-full flex justify-center items-center"
style="background-color: #55acee"
href="#!"
role="button"
data-mdb-ripple="true"
data-mdb-ripple-color="light"
>
<!-- Twitter -->
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"
class="w-3.5 h-3.5 mr-2"
>
<path
fill="currentColor"
d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"
/></svg>Continue with Twitter
</a>
</form>
</div>
</div>
</div>
</section>
</body>
</html>
{% extends 'base.html' %}
{% block main %}
{% include 'nav.html' %}
{% endblock %}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Todo list</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Prompt&display=swap" rel="stylesheet">
<script src="https://unpkg.com/flowbite@1.5.3/dist/datepicker.js"></script>
<style>
body{
font-family: 'Prompt', sans-serif;
}
</style>
</head>
<body >
{% block main %} {% endblock %}
<!-- component -->
<div class="bg-white dark:bg-gray-900 mt-5">
<div class="aler alert-danger " role="alert">
{% for message in messages %}
<b>{{message}}</b>
{% endfor %}
</div>
<div class="flex justify-center h-screen">
<div class="hidden bg-cover lg:block lg:w-2/3" style="background-image: url(https://gloriumtech.com/wp-content/uploads/2022/06/What-is-EMR-in-Healthcare.png)">
<div class="flex items-center h-full px-20 bg-opacity-40">
<div>
</div>
</div>
</div>
<div class="flex items-center w-full max-w-md px-6 mx-auto lg:w-2/6">
<div class="flex-1">
<div class="text-center">
<h2 class="text-4xl font-bold text-center text-gray-700 dark:text-white">Resiter</h2>
<p class="mt-3 text-gray-500 dark:text-gray-300">Sign in to access your account</p>
</div>
<div class="mt-8">
<form class="space-y-4 md:space-y-6" action="/register" method="post">
{% csrf_token %}
{{ user.username }}
<div>
<label for="" class="block mb-2 text-sm text-gray-600 dark:text-gray-200">username</label>
<input type="username" name="username" id="username" placeholder="Firtname.." class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-400 bg-white border border-gray-200 rounded-md dark:placeholder-gray-600 dark:bg-gray-900 dark:text-gray-300 dark:border-gray-700 focus:border-blue-400 dark:focus:border-blue-400 focus:ring-blue-400 focus:outline-none focus:ring focus:ring-opacity-40" />
</div>
<div>
<label for="" class="block mb-2 text-sm text-gray-600 dark:text-gray-200">Firstname</label>
<input type="text" name="first_name" id="first_name" placeholder="Firtname.." class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-400 bg-white border border-gray-200 rounded-md dark:placeholder-gray-600 dark:bg-gray-900 dark:text-gray-300 dark:border-gray-700 focus:border-blue-400 dark:focus:border-blue-400 focus:ring-blue-400 focus:outline-none focus:ring focus:ring-opacity-40" />
</div>
<div>
<label for="" class="block mb-2 text-sm text-gray-600 dark:text-gray-200">Lastname</label>
<input type="text" name="last_name" id="last_name" placeholder="Lastname..." class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-400 bg-white border border-gray-200 rounded-md dark:placeholder-gray-600 dark:bg-gray-900 dark:text-gray-300 dark:border-gray-700 focus:border-blue-400 dark:focus:border-blue-400 focus:ring-blue-400 focus:outline-none focus:ring focus:ring-opacity-40" />
</div>
<div>
<label for="email" class="block mb-2 text-sm text-gray-600 dark:text-gray-200">Email Address</label>
<input type="email" name="email" id="email" placeholder="@example.com" class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-400 bg-white border border-gray-200 rounded-md dark:placeholder-gray-600 dark:bg-gray-900 dark:text-gray-300 dark:border-gray-700 focus:border-blue-400 dark:focus:border-blue-400 focus:ring-blue-400 focus:outline-none focus:ring focus:ring-opacity-40" />
</div>
<div class="mt-6">
<div class="flex justify-between mb-1">
<label for="" class="text-sm text-gray-600 dark:text-gray-200">Password</label>
</div>
<div>
<input type="password" name="password1" id="password1" placeholder="Your Password" class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-400 bg-white border border-gray-200 rounded-md dark:placeholder-gray-600 dark:bg-gray-900 dark:text-gray-300 dark:border-gray-700 focus:border-blue-400 dark:focus:border-blue-400 focus:ring-blue-400 focus:outline-none focus:ring focus:ring-opacity-40" />
</div>
</div>
<div class="mt-6">
<div class="flex justify-between mb-1">
<label for="" class="text-sm text-gray-600 dark:text-gray-200">Repassword</label>
</div>
<div>
<input type="password" name="password2" id="password2" placeholder="agent a Password" class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-400 bg-white border border-gray-200 rounded-md dark:placeholder-gray-600 dark:bg-gray-900 dark:text-gray-300 dark:border-gray-700 focus:border-blue-400 dark:focus:border-blue-400 focus:ring-blue-400 focus:outline-none focus:ring focus:ring-opacity-40" />
</div>
<a href="#" class="ml-[60%] text-sm text-gray-400 focus:text-blue-500 hover:text-blue-500 hover:underline">Forgot password?</a>
<div class="mt-6">
<button
class="w-full px-4 py-2 tracking-wide text-white transition-colors duration-200 transform bg-blue-500 rounded-md hover:bg-blue-400 focus:outline-none focus:bg-blue-400 focus:ring focus:ring-blue-300 focus:ring-opacity-50">
Sign in
</button>
</div>
</form>
<p class="mt-6 text-sm text-center text-gray-400">Don&#x27;t have an account yet? <a href="#" class="text-blue-500 focus:outline-none focus:underline hover:underline">Sign up</a>.</p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
......@@ -2,14 +2,28 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>POS FOOD</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Todo list</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Prompt&display=swap" rel="stylesheet">
<script src="https://unpkg.com/flowbite@1.5.3/dist/datepicker.js"></script>
<style>
body{
font-family: 'Prompt', sans-serif;
}
</style>
</head>
<body>
<body >
<main class="min-h-screen bg-white-200 text-center">
{% block main %}
{% endblock %}
</main>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Todo list</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Prompt&display=swap" rel="stylesheet">
<script src="https://unpkg.com/flowbite@1.5.3/dist/datepicker.js"></script>
<style>
body{
font-family: 'Prompt', sans-serif;
}
</style>
</head>
<body >
</body>
</html>
\ No newline at end of file
{% extends 'index.html' %}
{% extends 'base.html' %}
{% block main %}
<h1>ระบบกำลังปรับปรุงจะกลับมาเร็วๆนี้
</h1>
{% include 'nav.html' %}
<h1>พี่เหน่งช่วยหนูด้วย</h1>
{% endblock %}
\ No newline at end of file
{% extends 'index.html' %}
{% block main %}
<h1>ระบบกำลังปรับปรุงจะกลับมาเร็วๆนี้
</h1>
{% endblock %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Project</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
{% include "components/header1.html" %}
<main class="min-h-screen bg-white-200 text-center">
{% block main %}
{% endblock %}
</main>
</body>
</html>
\ No newline at end of file
{% extends 'base.html' %}
{% block main %}
{% include 'nav.html' %}
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block main %}
<nav class="bg-white border-gray-200 dark:bg-gray-700">
<div class="flex flex-wrap justify-between items-center mx-auto max-w-screen-xl px-4 md:px-6 py-2.5">
<span class="self-center text-xl font-semibold whitespace-nowrap dark:text-white">Food Shop</span>
<div class="flex items-center">
{% if user.is_authenticated %}
<span class="text-white m-l-5">Welcome {{ user.username }}</span>
<a href="/logout" class="text-sm m-5 font-medium text-blue-600 dark:text-blue-500 hover:underline">Logout</a>
{% else %}
<a href="/login" class="text-sm m-5 font-medium text-blue-600 dark:text-blue-500 hover:underline">Login</a>
<a href="/register" class="text-sm font-medium text-blue-600 dark:text-blue-500 hover:underline">Register</a>
{% endif %}
</div>
</div>
</nav>
<nav class="bg-gray-50 dark:bg-gray-200">
<div class="py-3 px-4 mx-auto max-w-screen-xl md:px-6">
<div class="flex items-center">
<ul class="flex flex-row mt-0 mr-6 space-x-8 text-sm font-medium">
<li>
<a href="/index" class="text-gray-900 dark:text-black hover:underline" aria-current="page">หน้าหลัก</a>
</li>
<li>
<a href="/" class="text-gray-900 dark:text-black hover:underline">อาหารแนะนำ</a>
</li>
<li>
<a href="/contact" class="text-gray-900 dark:text-black hover:underline">ติดต่อเรา</a>
</li>
</ul>
</div>
</div>
</nav>
{% include 'nav.html' %}
{% endblock %}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Univ Web Project Login</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<!-- component -->
<section class="bg-gray-50 dark:bg-white">
<div class="flex flex-col items-center justify-center px-6 py-8 mx-auto md:h-screen lg:py-0">
<div class="w-full bg-white rounded-lg shadow dark:border md:mt-0 sm:max-w-md xl:p-0 dark:bg-white-800 dark:border-gray-700">
<div class="p-6 space-y-4 md:space-y-6 sm:p-8">
<h1 class="text-xl font-bold leading-tight tracking-tight text-gray-900 md:text-2xl dark:text-black">
Sign in to your account
</h1>
<form method="post" class="space-y-4 md:space-y-6" action="/login">
{% csrf_token %}
<div>
<label for="username" class="block mb-2 text-sm font-medium text-gray-900 dark:text-black">Username</label>
<input type="text" name="username" id="username" class="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-200 dark:border-gray-600 dark:placeholder-gray-400 dark:text-black dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Username">
</div>
<div>
<label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-black">Password</label>
<input type="password" name="password" id="password" placeholder="••••••••" class="bg-gray-50 border border-gray-300 text-black-900 sm:text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-200 dark:border-gray-600 dark:placeholder-gray-400 dark:text-black dark:focus:ring-blue-500 dark:focus:border-blue-500">
</div>
<a href="#" class="text-sm font-medium text-primary-600 hover:underline dark:text-primary-500">Forgot password?</a>
</div>
<div class="flex items-center justify-center">
<button type="submit" class="shadow-xl text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 mr-2 mb-2 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800">Login</button>
<button class="shadow-xl text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 mr-2 mb-2 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800"><a href="/index">Home</a></button>
</div>
</form>
</div>
</div>
</div>
</section>
</body>
</html>
\ No newline at end of file
<nav class="bg-gray-500 border-gray-200 dark:bg-gray-900">
<div class="flex flex-wrap justify-between items-center mx-auto max-w-screen-xl px-4 md:px-6 py-2.5">
<span class="self-center text-xl font-semibold whitespace-nowrap dark:text-white">Food Shop</span>
<div class="flex items-center">
{% if user.is_authenticated %}
<span class="text-white m-l-5">Welcome {{ user.username }}</span>
<a href="/logout" class="text-sm m-5 font-medium text-blue-600 dark:text-blue-500 hover:underline">Logout</a>
{% else %}
<a href="/login" class="text-sm m-5 font-medium text-blue-600 dark:text-blue-500 hover:underline">Login</a>
<a href="/register" class="text-sm font-medium text-blue-600 dark:text-blue-500 hover:underline">Register</a>
{% endif %}
</div>
</div>
</nav>
<nav class="bg-gray-50 dark:bg-gray-200">
<div class="py-3 px-4 mx-auto max-w-screen-xl md:px-6">
<div class="flex items-center">
<ul class="flex flex-row mt-0 mr-6 space-x-8 text-sm font-medium">
<li>
<a href="/" class="text-gray-900 dark:text-black hover:underline" aria-current="page">หน้าหลัก</a>
</li>
<li>
<a href="/" class="text-gray-900 dark:text-black hover:underline">อาหารแนะนำ</a>
</li>
<li>
<a href="/contact" class="text-gray-900 dark:text-black hover:underline">ติดต่อเรา</a>
</li>
</ul>
</div>
</div>
</nav>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="https://cdn.tailwindcss.com"></script>
<title>Register</title>
</head>
<body>
<section class="bg-gray-50 dark:bg-gray-900">
<div class="flex flex-col items-center justify-center px-6 py-8 mx-auto md:h-screen lg:py-0">
<div class="w-full bg-white rounded-lg shadow dark:border md:mt-0 sm:max-w-md xl:p-0 dark:bg-gray-800 dark:border-gray-700">
<div class="p-6 space-y-4 md:space-y-6 sm:p-8">
<h1 class="text-xl font-bold leading-tight tracking-tight text-gray-900 md:text-2xl dark:text-white">
Create and account
</h1>
<form method="post" class="space-y-4 md:space-y-6" action="">
{% csrf_token %}
<div>
<label for="email" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Username</label>
<input type="email" name="email" id="email" class="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Username" required="">
</div>
<div>
<label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Password</label>
<input type="password" name="password" id="password" placeholder="••••••••" class="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" required="">
</div>
<div>
<label for="confirm-password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Confirm password</label>
<input type="password" name="confirm-password" id="confirm-password" placeholder="••••••••" class="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" required="">
</div>
<div class="flex items-start">
</div>
<button type="submit" class="w-full bg-blue-600 text-white bg-primary-600 hover:bg-primary-700 focus:ring-4 focus:outline-none focus:ring-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800">Create an account</button>
<button class="center shadow-xl text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 mr-2 mb-2 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800"><a href="/index">Home</a></button>
</form>
</div>
</div>
</div>
</section>
</body>
</html>
\ No newline at end of file
......@@ -5,8 +5,13 @@ from django.shortcuts import render
from myapp.models import Post
urlpatterns = [
path("index",views.index),
path("login",views.login),
path("",views.home),
path("index",views.index,name="index"),
path("login",views.login,name="login"),
path('logout',views.logout,name="logout"),
path('userlogin',views.userlogin,name='userlogin'),
path("register",views.register),
path("member",views.member,name="member"),
path('contact', views.contact),
path('help', views.help,name='help'),
]
from django.shortcuts import render
from django.http import HttpResponse, HttpResponseRedirect
#from django.template import loader
from django.shortcuts import render, redirect
#from django.utils import timezone
from django.urls import reverse
from django.contrib.auth import authenticate,login # import form
from django.contrib.auth.models import User,auth
from django.contrib import messages
# Create your views here.
# index
def home(req):
return render(req,'home.html')
def index(req):
return render(req,'index.html')
def contact(req):
return render(req,'contact.html')
def login(req):
return render(req,'login.html')
def register(req):
return render(req,'register.html')
def login(request):
return render(request,'account/login.html')
def userlogin(request):
username = request.POST['username']
password = request.POST['password']
user = auth.authenticate(request,username=username,password=password)
if user is not None :
auth.login(request, user)
return HttpResponseRedirect(reverse('index'))
else:
return redirect('login')
def logout(request):
auth.logout(request)
return redirect('/')
# Register
def member(request):
return render(request,"account/member.html")
def register(request):
if request.method == "POST":
# POST
username = request.POST['username']
first_name = request.POST['first_name']
last_name = request.POST['last_name']
email = request.POST['email']
password1 = request.POST['password1']
password2 = request.POST['password2']
if password1 == password2 :
if User.objects.filter(username=username).exists():
messages.info(request,"user ใช้ไปแล้ว")
return redirect('todos:register')
elif User.objects.filter(email=email).exists():
messages.info(request,"Email ใช้ไปแล้ว")
return redirect('todos:register')
else:
myuser = User.objects.create_user(username=username,first_name=first_name,
last_name=last_name,email=email,password=password1)
myuser.save()
messages.success(request,'Your Accout has been sucessfuly created.')
return redirect('member')
else:
messages.success(request,'Password ไม่ถุกต้อง')
return render(request,'account/register.html')
return render(request,'account/register.html')
# help
def help(request):
return render(request,'help.html')
\ No newline at end of file
......@@ -121,7 +121,10 @@ USE_TZ = True
STATIC_URL = '/static/'
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment