Skip to content

Commit

Permalink
project init
Browse files Browse the repository at this point in the history
  • Loading branch information
sky1045 committed Jan 25, 2019
0 parents commit 3623c52
Show file tree
Hide file tree
Showing 960 changed files with 144,828 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions .idea/piro10th.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

510 changes: 510 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

Binary file added article/.urls.py.swp
Binary file not shown.
Empty file added article/__init__.py
Empty file.
Binary file added article/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file added article/__pycache__/admin.cpython-36.pyc
Binary file not shown.
Binary file added article/__pycache__/models.cpython-36.pyc
Binary file not shown.
Binary file added article/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file added article/__pycache__/views.cpython-36.pyc
Binary file not shown.
6 changes: 6 additions & 0 deletions article/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.contrib import admin

# Register your models here.
from article.models import Article

admin.site.register(Article)
5 changes: 5 additions & 0 deletions article/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class ArticleConfig(AppConfig):
name = 'article'
24 changes: 24 additions & 0 deletions article/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 2.1.5 on 2019-01-25 04:52

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Article',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=20, verbose_name='제목')),
('content', models.TextField(verbose_name='내용')),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
],
),
]
Empty file added article/migrations/__init__.py
Empty file.
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions article/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.db import models

# Create your models here.
class Article(models.Model):
title = models.CharField(max_length=20, verbose_name='제목')
content = models.TextField(verbose_name='내용')

created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

Binary file added article/templates/.list.html.swp
Binary file not shown.
14 changes: 14 additions & 0 deletions article/templates/create.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% extends 'base.html' %}

{% block content %}
<form method="POST">
{% csrf_token %}
<input type="text", name="title" />
<label for="title">제목</label>
<br/>
<textarea name="content" ></textarea>
<label for="content">내용</label>
<br/>
<button type="submit" class="btn btn-primary">생성</button>
</form>
{% endblock %}
8 changes: 8 additions & 0 deletions article/templates/detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends 'base.html' %}

{% block content %}
<div class="jumbotron">
<h1 class="display-4">{{ article1.title }}</h1>
<p class="lead">{{ article1.content }}</p>
</div>
{% endblock %}
28 changes: 28 additions & 0 deletions article/templates/list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% extends 'base.html' %}

{% block content %}
<h1>articles</h1>
<table class="table">
<thead>
<tr>
<th scope="col">id</th>
<th scope="col">title</th>
<th scope="col">created_at</th>
</tr>
</thead>
<tbody>
{% for article in articles %}
<tr>
<td>{{ article.id }}</td>
<td>
<a href="{% url 'detail' article.id %}">
{{ article.title }}
</a>
</td>
<td>{{ article.created_at }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<a href="{% url 'create' %}"><button class="btn btn-warning">게시글 작성</button></a>
{% endblock %}
3 changes: 3 additions & 0 deletions article/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
8 changes: 8 additions & 0 deletions article/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.urls import path
from .views import *

urlpatterns = [
path('', list_article, name='list'),
path('<int:pk>/', detail_article, name='detail'),
path('create/', create_article, name='create'),
]
34 changes: 34 additions & 0 deletions article/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from django.shortcuts import render

# Create your views here.
from article.models import Article
from django.shortcuts import redirect


def list_article(request):
articles = Article.objects.all()
data = {
'articles': articles
}
return render(request, 'list.html', data)


def detail_article(request, pk):
article = Article.objects.get(pk=pk)
data = {
'article1': article
}
return render(request, 'detail.html', data)


def create_article(request):
if request.method == 'POST':
title = request.POST.get('title', None)
content = request.POST['content']
article = Article.objects.create(
title=title,
content=content
)
return redirect('/')
return render(request, 'create.html')

Binary file added db.sqlite3
Binary file not shown.
15 changes: 15 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
import os
import sys

if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'piro10th.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)
Binary file added piro10th/.urls.py.swp
Binary file not shown.
Empty file added piro10th/__init__.py
Empty file.
Binary file added piro10th/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file added piro10th/__pycache__/settings.cpython-36.pyc
Binary file not shown.
Binary file added piro10th/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file added piro10th/__pycache__/wsgi.cpython-36.pyc
Binary file not shown.
122 changes: 122 additions & 0 deletions piro10th/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
"""
Django settings for piro10th project.
Generated by 'django-admin startproject' using Django 2.1.5.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/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.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '^6=p=zqis^t9g65(94#kz27bb+9zqk!yj=poyhh&((zdmy627*'

# 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',

'article',
]

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

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, '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 = 'piro10th.wsgi.application'


# Database
# https://docs.djangoproject.com/en/2.1/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.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/2.1/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/2.1/howto/static-files/

STATIC_URL = '/static/'
27 changes: 27 additions & 0 deletions piro10th/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""piro10th URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.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
from article.views import (
list_article,
detail_article,
create_article,
)

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

import os

from django.core.wsgi import get_wsgi_application

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

application = get_wsgi_application()
Loading

0 comments on commit 3623c52

Please sign in to comment.