Author: {{ object.author }}
10 |├── myblog ├── accounts │ ├── __init__.py │ ├── migrations │ │ └── __init__.py │ ├── models.py │ ├── tests.py │ ├── admin.py │ ├── apps.py │ ├── views.py │ ├── urls.py │ └── templates │ │ └── accounts │ │ └── signup.html ├── blogs │ ├── __init__.py │ ├── migrations │ │ ├── __init__.py │ │ └── 0001_initial.py │ ├── tests.py │ ├── admin.py │ ├── apps.py │ ├── templates │ │ └── blogs │ │ │ ├── post_confirm_delete.html │ │ │ ├── post_form.html │ │ │ ├── post_detail.html │ │ │ └── post_list.html │ ├── models.py │ ├── urls.py │ └── views.py ├── myblog │ ├── __init__.py │ ├── wsgi.py │ ├── urls.py │ └── settings.py ├── templates │ ├── registration │ │ ├── logged_out.html │ │ └── login.html │ ├── 404.html │ ├── 403.html │ └── base.html ├── manage.py └── static │ └── css │ └── style.css ├── README.md └── .gitignore /myblog/accounts/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /myblog/blogs/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /myblog/myblog/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /myblog/accounts/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /myblog/blogs/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /myblog/blogs/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /myblog/accounts/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /myblog/accounts/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /myblog/accounts/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /myblog/blogs/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import Post 3 | 4 | admin.site.register(Post) 5 | -------------------------------------------------------------------------------- /myblog/blogs/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class BlogsConfig(AppConfig): 5 | name = 'blogs' 6 | -------------------------------------------------------------------------------- /myblog/accounts/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AccountsConfig(AppConfig): 5 | name = 'accounts' 6 | -------------------------------------------------------------------------------- /myblog/templates/registration/logged_out.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %}Logout{% endblock %} 4 | 5 | {% block content %} 6 |
Thanks for spending some quality time with the Web site today.
8 | 9 | {% endblock %} 10 | -------------------------------------------------------------------------------- /myblog/accounts/views.py: -------------------------------------------------------------------------------- 1 | from django.contrib.auth.forms import UserCreationForm 2 | from django.urls import reverse_lazy 3 | from django.views import generic 4 | 5 | 6 | class SignUpView(generic.CreateView): 7 | form_class = UserCreationForm 8 | success_url = reverse_lazy('login') 9 | template_name = 'accounts/signup.html' 10 | -------------------------------------------------------------------------------- /myblog/accounts/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | 3 | from . import views 4 | 5 | # set the application namespace 6 | # https://docs.djangoproject.com/en/2.0/intro/tutorial03/ 7 | app_name = 'accounts' 8 | 9 | urlpatterns = [ 10 | # ex: /accounts/signup/ 11 | path('signup/', views.SignUpView.as_view(), name='signup'), 12 | ] 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Django2 Tutorial - Simple Blog App with Auth - 2 | 3 | ## Django2 でユーザー認証(ログイン認証)を実装するチュートリアル 4 | 1. [環境構築とアプリ雛形の作成](https://it-engineer-lab.com/archives/506) 5 | 1. [サインアップとログイン・ログアウト](https://it-engineer-lab.com/archives/554) 6 | 1. [ブログアプリへの実装](https://it-engineer-lab.com/archives/737) 7 | 8 | ## デモサイト 9 | [https://tutorialauth.it-engineer-lab.com/](https://tutorialauth.it-engineer-lab.com/) -------------------------------------------------------------------------------- /myblog/accounts/templates/accounts/signup.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %}Sign up{% endblock %} 4 | 5 | {% block content %} 6 |The requested URL {{ request.get_full_path }} was not found on this server.
10 |Sorry, it appears the page you were looking for is forbidden and not accessible.
11 | {% if exception %} 12 |{{ exception }}
13 | {% endif %} 14 |Are you sure you want to delete "{{ object.title }}" ?
9 | 12 |Author: {{ object.author }}
10 |Created: {{ object.created_at }}/Updated: {{ object.updated_at }}
13 |Your username and password didn't match. Please try again.
10 | {% endif %} 11 | 12 | {% if next %} 13 | {% if user.is_authenticated %} 14 |Your account doesn't have access to this page. To proceed, 15 | please login with an account that has access.
16 | {% else %} 17 |Please login to see this page.
18 | {% endif %} 19 | {% endif %} 20 | 21 | 27 |{{ user }}
10 | {% endif %} 11 | 12 |{{ post.text }}
19 |No articles yet.
23 |