sipp11
2 years ago
commit
a58b7ec818
36 changed files with 896 additions and 0 deletions
@ -0,0 +1,5 @@ |
|||||||
|
.DS_Store |
||||||
|
__pycache__ |
||||||
|
*.pyc |
||||||
|
.vscode |
||||||
|
*.sqlite3 |
@ -0,0 +1,16 @@ |
|||||||
|
""" |
||||||
|
ASGI config for Djangoproject 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.1/howto/deployment/asgi/ |
||||||
|
""" |
||||||
|
|
||||||
|
import os |
||||||
|
|
||||||
|
from django.core.asgi import get_asgi_application |
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Djangoproject.settings') |
||||||
|
|
||||||
|
application = get_asgi_application() |
@ -0,0 +1,136 @@ |
|||||||
|
""" |
||||||
|
Django settings for Djangoproject project. |
||||||
|
|
||||||
|
Generated by 'django-admin startproject' using Django 3.1. |
||||||
|
|
||||||
|
For more information on this file, see |
||||||
|
https://docs.djangoproject.com/en/3.1/topics/settings/ |
||||||
|
|
||||||
|
For the full list of settings and their values, see |
||||||
|
https://docs.djangoproject.com/en/3.1/ref/settings/ |
||||||
|
""" |
||||||
|
|
||||||
|
from pathlib import Path |
||||||
|
import os |
||||||
|
# Build paths inside the project like this: BASE_DIR / 'subdir'. |
||||||
|
BASE_DIR = Path(__file__).resolve(strict=True).parent.parent |
||||||
|
|
||||||
|
|
||||||
|
# Quick-start development settings - unsuitable for production |
||||||
|
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ |
||||||
|
|
||||||
|
# SECURITY WARNING: keep the secret key used in production secret! |
||||||
|
SECRET_KEY = '9t4uov^!)o-08xxy^)(h9n7_a_tl_=j81ugwv&wl-)%n$pf3hs' |
||||||
|
|
||||||
|
# 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', |
||||||
|
'Mywebsite', |
||||||
|
'ckeditor', |
||||||
|
'django_wysiwyg', |
||||||
|
] |
||||||
|
|
||||||
|
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 = 'Djangoproject.urls' |
||||||
|
|
||||||
|
TEMPLATES = [ |
||||||
|
{ |
||||||
|
'BACKEND': 'django.template.backends.django.DjangoTemplates', |
||||||
|
'DIRS': [os.path.join(BASE_DIR,'Mywebsite', '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 = 'Djangoproject.wsgi.application' |
||||||
|
|
||||||
|
|
||||||
|
# Database |
||||||
|
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases |
||||||
|
|
||||||
|
DATABASES = { |
||||||
|
'default': { |
||||||
|
'NAME': 'db.sqlite3', |
||||||
|
'ENGINE': 'django.db.backends.sqlite3', |
||||||
|
'USER': '', |
||||||
|
'PASSWORD': '' |
||||||
|
}, |
||||||
|
# 'default': { |
||||||
|
# 'ENGINE': 'django.db.backends.mysql', |
||||||
|
# 'NAME':'mydjango', |
||||||
|
# 'USER':'root', |
||||||
|
# 'HOST':'localhost', |
||||||
|
# 'PORT':'' |
||||||
|
# }, |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
# Password validation |
||||||
|
# https://docs.djangoproject.com/en/3.1/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.1/topics/i18n/ |
||||||
|
|
||||||
|
LANGUAGE_CODE = 'th-TH' |
||||||
|
|
||||||
|
TIME_ZONE = 'Asia/Bangkok' |
||||||
|
|
||||||
|
USE_I18N = True |
||||||
|
|
||||||
|
USE_L10N = True |
||||||
|
|
||||||
|
USE_TZ = True |
||||||
|
|
||||||
|
|
||||||
|
# Static files (CSS, JavaScript, Images) |
||||||
|
# https://docs.djangoproject.com/en/3.1/howto/static-files/ |
||||||
|
|
||||||
|
STATIC_URL = '/static/' |
||||||
|
MEDIA_ROOT = os.path.join(BASE_DIR,'media') |
||||||
|
MEDIA_URL = '/media/' |
||||||
|
|
||||||
|
DJANGO_WYSIWYG_FLAVOR = "ckeditor" |
@ -0,0 +1,24 @@ |
|||||||
|
"""Djangoproject URL Configuration |
||||||
|
|
||||||
|
The `urlpatterns` list routes URLs to views. For more information please see: |
||||||
|
https://docs.djangoproject.com/en/3.1/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.contrib import admin |
||||||
|
from django.urls import path,include |
||||||
|
|
||||||
|
urlpatterns = [ |
||||||
|
path('admin/', admin.site.urls), |
||||||
|
path('',include('Mywebsite.urls')), |
||||||
|
] |
||||||
|
handler404 = 'Mywebsite.views.handler404' |
||||||
|
|
@ -0,0 +1,16 @@ |
|||||||
|
""" |
||||||
|
WSGI config for Djangoproject 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.1/howto/deployment/wsgi/ |
||||||
|
""" |
||||||
|
|
||||||
|
import os |
||||||
|
|
||||||
|
from django.core.wsgi import get_wsgi_application |
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Djangoproject.settings') |
||||||
|
|
||||||
|
application = get_wsgi_application() |
@ -0,0 +1,4 @@ |
|||||||
|
from django.contrib import admin |
||||||
|
from .models import tb_news |
||||||
|
# Register your models here. |
||||||
|
admin.site.register(tb_news) |
@ -0,0 +1,5 @@ |
|||||||
|
from django.apps import AppConfig |
||||||
|
|
||||||
|
|
||||||
|
class MywebsiteConfig(AppConfig): |
||||||
|
name = 'Mywebsite' |
@ -0,0 +1,24 @@ |
|||||||
|
# Generated by Django 3.1 on 2020-08-30 09:36 |
||||||
|
|
||||||
|
from django.db import migrations, models |
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration): |
||||||
|
|
||||||
|
initial = True |
||||||
|
|
||||||
|
dependencies = [ |
||||||
|
] |
||||||
|
|
||||||
|
operations = [ |
||||||
|
migrations.CreateModel( |
||||||
|
name='tb_news', |
||||||
|
fields=[ |
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||||
|
('news_title', models.CharField(max_length=300)), |
||||||
|
('news_detail', models.TextField()), |
||||||
|
('news_photo', models.ImageField(default='', upload_to='photo')), |
||||||
|
('news_date', models.DateTimeField(auto_now=True)), |
||||||
|
], |
||||||
|
), |
||||||
|
] |
@ -0,0 +1,19 @@ |
|||||||
|
# Generated by Django 3.1 on 2020-09-01 17:53 |
||||||
|
|
||||||
|
import ckeditor.fields |
||||||
|
from django.db import migrations |
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration): |
||||||
|
|
||||||
|
dependencies = [ |
||||||
|
('Mywebsite', '0001_initial'), |
||||||
|
] |
||||||
|
|
||||||
|
operations = [ |
||||||
|
migrations.AlterField( |
||||||
|
model_name='tb_news', |
||||||
|
name='news_detail', |
||||||
|
field=ckeditor.fields.RichTextField(blank=True, null=True), |
||||||
|
), |
||||||
|
] |
@ -0,0 +1,18 @@ |
|||||||
|
# Generated by Django 3.1 on 2020-09-02 07:45 |
||||||
|
|
||||||
|
from django.db import migrations, models |
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration): |
||||||
|
|
||||||
|
dependencies = [ |
||||||
|
('Mywebsite', '0002_auto_20200902_0053'), |
||||||
|
] |
||||||
|
|
||||||
|
operations = [ |
||||||
|
migrations.AlterField( |
||||||
|
model_name='tb_news', |
||||||
|
name='news_detail', |
||||||
|
field=models.TextField(default=''), |
||||||
|
), |
||||||
|
] |
@ -0,0 +1,19 @@ |
|||||||
|
# Generated by Django 3.1 on 2020-09-02 08:34 |
||||||
|
|
||||||
|
import ckeditor.fields |
||||||
|
from django.db import migrations |
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration): |
||||||
|
|
||||||
|
dependencies = [ |
||||||
|
('Mywebsite', '0003_auto_20200902_1445'), |
||||||
|
] |
||||||
|
|
||||||
|
operations = [ |
||||||
|
migrations.AlterField( |
||||||
|
model_name='tb_news', |
||||||
|
name='news_detail', |
||||||
|
field=ckeditor.fields.RichTextField(blank=True, null=True), |
||||||
|
), |
||||||
|
] |
@ -0,0 +1,15 @@ |
|||||||
|
from django.db import models |
||||||
|
from django.core.files.storage import FileSystemStorage |
||||||
|
import os |
||||||
|
from ckeditor.fields import RichTextField |
||||||
|
# Create your models here. |
||||||
|
|
||||||
|
class tb_news(models.Model): |
||||||
|
news_title = models.CharField(max_length=300) |
||||||
|
#news_detail = models.TextField(default='') |
||||||
|
news_detail = RichTextField(blank=True,null=True) |
||||||
|
news_photo = models.ImageField(upload_to='photo',default='') |
||||||
|
news_date = models.DateTimeField(auto_now=True,blank=False) |
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,13 @@ |
|||||||
|
|
||||||
|
body{ |
||||||
|
background-color: rgb(251, 251, 251); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
img { |
||||||
|
max-width: 100%; |
||||||
|
height: auto !important; |
||||||
|
display: block; |
||||||
|
margin-left: auto; |
||||||
|
margin-right: auto; |
||||||
|
} |
After Width: | Height: | Size: 403 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 12 KiB |
@ -0,0 +1,19 @@ |
|||||||
|
{% extends 'Mywebsite/header.html' %} |
||||||
|
{% block content %} |
||||||
|
<br> |
||||||
|
|
||||||
|
{% for data in result %} |
||||||
|
<input type="hidden" value="{{data.id}}" name="id"> |
||||||
|
<div class='form-group'> |
||||||
|
<h1>{{data.news_title}}</h1> |
||||||
|
</div> |
||||||
|
|
||||||
|
|
||||||
|
<div class="shadow p-3 mb-5 bg-white rounded"> |
||||||
|
|
||||||
|
<div class="card-body"> |
||||||
|
<p>{{data.news_detail | safe }}</p> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
{%endfor%} |
||||||
|
{% endblock %} |
@ -0,0 +1,3 @@ |
|||||||
|
from django.test import TestCase |
||||||
|
|
||||||
|
# Create your tests here. |
@ -0,0 +1,24 @@ |
|||||||
|
from django.urls import path |
||||||
|
from . import views |
||||||
|
from django.conf import settings |
||||||
|
from django.conf.urls.static import static |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
urlpatterns = [ |
||||||
|
path('',views.index), |
||||||
|
path('addnews/',views.addnews), |
||||||
|
path('addnewsdata/',views.addnewsdata,name='addnewsdata'), |
||||||
|
path('contentmanager/',views.contentmanager), |
||||||
|
path('contentedit/',views.contentedit,name='contentedit'), |
||||||
|
path('contentupdate/',views.contentupdate,name='contentupdate'), |
||||||
|
path('contentdelete/',views.contentdelete,name='contentdelete'), |
||||||
|
path('contentresult/',views.contentresult,name='contentresult'), |
||||||
|
path('regisuser/',views.regisuser), |
||||||
|
path('regisuserdata/',views.regisuserdata,name='regisuserdata'), |
||||||
|
path('login/',views.login), |
||||||
|
path('logincheck/',views.logincheck,name='logincheck'), |
||||||
|
path('logoff/',views.logoff), |
||||||
|
path('warning/',views.warning) |
||||||
|
] + static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT) + static(settings.STATIC_URL,document_root=settings.STATIC_ROOT) |
||||||
|
|
@ -0,0 +1,10 @@ |
|||||||
|
#!/usr/bin/env python |
||||||
|
import os |
||||||
|
import sys |
||||||
|
|
||||||
|
if __name__ == "__main__": |
||||||
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Djangoproject.settings") |
||||||
|
|
||||||
|
from django.core.management import execute_from_command_line |
||||||
|
|
||||||
|
execute_from_command_line(sys.argv) |
Loading…
Reference in new issue