Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Round3]객체 & SQL #33

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
122 changes: 122 additions & 0 deletions GalaxyDimension/Round1/Django CRUD/costory/costory/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
"""
Django settings for costory project.

Generated by 'django-admin startproject' using Django 2.2.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'd=cwoga(*8k%s#-rl)3q1#6$!$kh2k36#(qrsy!@u+k!b@hmgc'

# 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',
'posts',
#'django_seed'
]

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 = 'costory.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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 = 'costory.wsgi.application'


# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}


# Password validation
# https://docs.djangoproject.com/en/2.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/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Seoul'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_URL = '/static/'
23 changes: 23 additions & 0 deletions GalaxyDimension/Round1/Django CRUD/costory/costory/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""costory URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.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.contrib import admin
from django.urls import path
from django.urls import include

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('posts.urls'))
]
16 changes: 16 additions & 0 deletions GalaxyDimension/Round1/Django CRUD/costory/costory/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for costory 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/2.2/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'costory.settings')

application = get_wsgi_application()
21 changes: 21 additions & 0 deletions GalaxyDimension/Round1/Django CRUD/costory/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'costory.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()
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions GalaxyDimension/Round1/Django CRUD/costory/posts/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.contrib import admin
from .models import Post


# Register your models here.
admin.site.register(Post)
5 changes: 5 additions & 0 deletions GalaxyDimension/Round1/Django CRUD/costory/posts/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class PostsConfig(AppConfig):
name = 'posts'
23 changes: 23 additions & 0 deletions GalaxyDimension/Round1/Django CRUD/costory/posts/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from django import forms
from django.core.exceptions import ValidationError
from .models import Post
from .validators import validate_symbols


class PostForm(forms.ModelForm):

class Meta:
model = Post
fields = ['title', 'content']
widgets = {
'title': forms.TextInput(attrs={
'class': 'title',
'placeholder': '제목을 입력하세요'}),
'content': forms.Textarea(attrs={
'placeholder': '내용을 입력하세요'})}

def clean_title(self):
title = self.cleaned_data['title']
if '*' in title:
raise ValidationError('* 는 포함될 수 없습니다.')
return title
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 2.2 on 2020-10-22 06:18

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Post',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=50)),
('content', models.TextField()),
('dt_created', models.DateTimeField(auto_now_add=True, verbose_name='Created Date')),
('dt_modified', models.DateTimeField(auto_now=True, verbose_name='Modified Date')),
],
),
]
Empty file.
Binary file not shown.
Binary file not shown.
17 changes: 17 additions & 0 deletions GalaxyDimension/Round1/Django CRUD/costory/posts/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.db import models
from django.core.validators import MinLengthValidator
from .validators import validate_symbols

# Create your models here.
class Post(models.Model):
title = models.CharField(max_length=50, unique=True,
error_messages={'unique': '이미 있는 제목이네요!'})
content = models.TextField(validators=[
MinLengthValidator(10, '너무 짧군요! 10자 이상 적어주세요.'),
validate_symbols
])
dt_created = models.DateTimeField(verbose_name="Date Created", auto_now_add=True)
dt_modified = models.DateTimeField(verbose_name="Date Modified", auto_now=True)

def __str__(self):
return self.title
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.error {
color : red;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
h1,h2,h3,p,a,ul,li{
margin: 0;
padding: 0;
font-family : 'NanumMyeongjo';
font-weight: 200;
list-style: none;
text-decoration: none;
outline: none;
color: black;
}
a:hover,a:active,button:hover {
text-decoration: none;
}
html{
position: relative;
min-height: 100%;
margin: 0;
}
body {
min-height: 100%;
margin: 0;
padding: 0;
background: #2b2a2e;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: auto;
}
img {
margin: 0;
padding: 0;
border: 0;
}

#nav{
height: 60px;
}
#content{
margin-top: 160px;
margin-bottom: 300px;
}
#footer{
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 75px;
background: rgba(41, 41, 44, 0.7);
}
.container{
width: 800px;
margin: 0 auto;
}

.logo{
width: 65%;
min-width: 899px;
margin: 0 auto;
padding-top: 17px;
}
.logo img{
width: 88px;
}
.confirm{
padding: 108px 0 124px;
text-align: center;
background: #fff;
}
p{
font-size: 17px;
color: #575362;
letter-spacing: -0.35px;
}
p.title{
padding-bottom: 8px;
font-size: 20px;
font-weight: bold;
color: #333236;
letter-spacing: -0.45px;
}
.confirm_btn{
padding-top: 46px;
}
.confirm_btn ul li{
display: inline-block;
}
.confirm_btn input{

display: inline-block;
margin-left: 18px;
padding: 10px 19px 11px;
font-size: 15px;
color: #69666d;
background: #f6f6f6;
border: none;
}
.confirm_btn a{
display: inline-block;
margin-left: 18px;
padding: 10px 19px 11px;
font-size: 15px;
color: #69666d;
background: #f6f6f6;
border: none;
}
.confirm_btn input:hover{
color: red;
transition: all .2s;
}
.footer{
width: 65%;
min-width: 899px;
margin: 0 auto;
}
.footer p{
text-align: right;
font-size: 20px;
line-height: 75px;
font-weight: 800;
letter-spacing: -0.85px;
color: #53534f;
}
Loading