Commit bbe1069a authored by phatiphan.th.63's avatar phatiphan.th.63

project

parents
Pipeline #1829 failed with stages
File added
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class MyappConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'myapp'
from django.db import models
# Create your models here.
<!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 class="bg-white">
{% block main %} {% endblock %}
</body>
</html>
\ No newline at end of file
<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="/sciweb/main" 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="/sciweb/contact" class="text-gray-900 dark:text-black hover:underline">ติดต่อเรา</a>
</li>
</ul>
</div>
</div>
</nav>
\ 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="/" 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="/" class="text-gray-900 dark:text-black hover:underline">ติดต่อเรา</a>
</li>
</ul>
</div>
</div>
</nav>
{% endblock %}
\ No newline at end of file
<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="/" 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="/" class="text-gray-900 dark:text-black hover:underline">ติดต่อเรา</a>
</li>
</ul>
</div>
</div>
</nav>
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.urls import path
from . import views
urlpatterns = [
path("index",views.index,name='index'),
path("nav",views.index,name='nav')
]
from django.shortcuts import render
# Create your views here.
def index(req):
return render(req,'index.html')
def nav(req):
return render(req,'navbar.html')
\ No newline at end of file
"""
ASGI config for project project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
application = get_asgi_application()
"""
Django settings for project project.
Generated by 'django-admin startproject' using Django 3.2.5.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-dp(55*(q98&s_o22a0%au)g@w*d_4r(+2ieu18!&c^0hb37_rc'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'project.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR,'myapp/templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'project.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
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'
"""project URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.contrib import admin
from django.contrib.auth.models import User
from django.shortcuts import render, redirect
from django.urls import path, include
from django.conf.urls.static import static
from django.contrib.auth import authenticate, login as authlogin
from django.contrib.auth import logout as authlogout
urlpatterns = [
path("",include('myapp.urls')),
path("admin/", admin.site.urls),
]
"""
WSGI config for project project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
application = get_wsgi_application()
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