Skip to content

Commit

Permalink
チュートリアルのソースコード一式
Browse files Browse the repository at this point in the history
  • Loading branch information
toksan committed Jan 4, 2018
0 parents commit 0982605
Show file tree
Hide file tree
Showing 23 changed files with 796 additions and 0 deletions.
199 changes: 199 additions & 0 deletions .gitignore
@@ -0,0 +1,199 @@
myenv/
.idea/

# Created by https://www.gitignore.io/api/python

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# End of https://www.gitignore.io/api/python


# Created by https://www.gitignore.io/api/django

### Django ###
*.log
*.pot
*.pyc
__pycache__/
local_settings.py
db.sqlite3
media

# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
# in your Git repository. Update and uncomment the following line accordingly.
# <django-project-name>/staticfiles/

# End of https://www.gitignore.io/api/django



# Created by https://www.gitignore.io/api/pycharm

### PyCharm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries

# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle:
.idea/**/gradle.xml
.idea/**/libraries

# CMake
cmake-build-debug/

# Mongo Explorer plugin:
.idea/**/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Ruby plugin and RubyMine
/.rakeTasks

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

### PyCharm Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
.idea/sonarlint

# End of https://www.gitignore.io/api/pycharm

12 changes: 12 additions & 0 deletions README.md
@@ -0,0 +1,12 @@
# Django2 Tutorial - Simple Blog App -

## Django2 入門チュートリアル – CRUDの基本を簡単なサンプルで学ぶ
1. [環境準備](https://it-engineer-lab.com/archives/331)
1. [モデルとマイグレーション](https://it-engineer-lab.com/archives/337)
1. [Django Admin](https://it-engineer-lab.com/archives/379)

## デモサイト
[http://tutorialblog.it-engineer-lab.com/](http://tutorialblog.it-engineer-lab.com/)

ベーシック認証
Username: demo / Password: blog
Empty file added myblog/blogs/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions myblog/blogs/admin.py
@@ -0,0 +1,4 @@
from django.contrib import admin
from .models import Post

admin.site.register(Post)
5 changes: 5 additions & 0 deletions myblog/blogs/apps.py
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class BlogsConfig(AppConfig):
name = 'blogs'
28 changes: 28 additions & 0 deletions myblog/blogs/migrations/0001_initial.py
@@ -0,0 +1,28 @@
# Generated by Django 2.0 on 2017-12-29 04:07

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

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=255)),
('text', models.TextField()),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
Empty file.
25 changes: 25 additions & 0 deletions myblog/blogs/models.py
@@ -0,0 +1,25 @@
from django.db import models
from django.urls import reverse


class Post(models.Model):
title = models.CharField(max_length=255)
text = models.TextField()
author = models.ForeignKey(
'auth.User',
on_delete=models.CASCADE,
)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

def __str__(self):
return self.title

def get_absolute_url(self):
"""
更処理完了時の戻り先URL
@link: https://docs.djangoproject.com/ja/2.0/ref/class-based-views/generic-editing/
:return:
"""
# return reverse('blogs:detail', kwargs={'pk': self.pk})
return reverse('blogs:index')

0 comments on commit 0982605

Please sign in to comment.