From 22c6fc29d0e4e30b9d8e1db29f6ac9699a4787f5 Mon Sep 17 00:00:00 2001 From: happine2s Date: Fri, 15 Jul 2022 15:37:53 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=EA=B5=AC=EA=B8=80=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rememB/balanceapp/urls.py | 6 ++++++ rememB/letterapp/models.py | 2 -- rememB/letterapp/urls.py | 6 ++++++ rememB/mainapp/admin.py | 3 ++- rememB/mainapp/migrations/0001_initial.py | 21 +++++++++++++++++++++ rememB/mainapp/models.py | 3 ++- rememB/mainapp/templates/mainapp/login.html | 15 +++++++++++++++ rememB/mainapp/urls.py | 6 ++++++ rememB/mainapp/views.py | 3 ++- rememB/rememB/settings.py | 16 ++++++++++++++++ rememB/rememB/urls.py | 21 +++++---------------- 11 files changed, 81 insertions(+), 21 deletions(-) create mode 100644 rememB/balanceapp/urls.py create mode 100644 rememB/letterapp/urls.py create mode 100644 rememB/mainapp/migrations/0001_initial.py create mode 100644 rememB/mainapp/templates/mainapp/login.html create mode 100644 rememB/mainapp/urls.py diff --git a/rememB/balanceapp/urls.py b/rememB/balanceapp/urls.py new file mode 100644 index 0000000..6147f3a --- /dev/null +++ b/rememB/balanceapp/urls.py @@ -0,0 +1,6 @@ +from django.urls import path +from . import views + +urlpatterns=[ + +] diff --git a/rememB/letterapp/models.py b/rememB/letterapp/models.py index 71a8362..137941f 100644 --- a/rememB/letterapp/models.py +++ b/rememB/letterapp/models.py @@ -1,3 +1 @@ from django.db import models - -# Create your models here. diff --git a/rememB/letterapp/urls.py b/rememB/letterapp/urls.py new file mode 100644 index 0000000..6147f3a --- /dev/null +++ b/rememB/letterapp/urls.py @@ -0,0 +1,6 @@ +from django.urls import path +from . import views + +urlpatterns=[ + +] diff --git a/rememB/mainapp/admin.py b/rememB/mainapp/admin.py index 8c38f3f..39db4df 100644 --- a/rememB/mainapp/admin.py +++ b/rememB/mainapp/admin.py @@ -1,3 +1,4 @@ from django.contrib import admin +from .models import Blog -# Register your models here. +admin.site.register(Blog) \ No newline at end of file diff --git a/rememB/mainapp/migrations/0001_initial.py b/rememB/mainapp/migrations/0001_initial.py new file mode 100644 index 0000000..87541f2 --- /dev/null +++ b/rememB/mainapp/migrations/0001_initial.py @@ -0,0 +1,21 @@ +# Generated by Django 4.0.6 on 2022-07-15 13:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Blog', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('text', models.TextField()), + ], + ), + ] diff --git a/rememB/mainapp/models.py b/rememB/mainapp/models.py index 71a8362..2ddc9c2 100644 --- a/rememB/mainapp/models.py +++ b/rememB/mainapp/models.py @@ -1,3 +1,4 @@ from django.db import models -# Create your models here. +class Blog(models.Model): + text=models.TextField() \ No newline at end of file diff --git a/rememB/mainapp/templates/mainapp/login.html b/rememB/mainapp/templates/mainapp/login.html new file mode 100644 index 0000000..68f2892 --- /dev/null +++ b/rememB/mainapp/templates/mainapp/login.html @@ -0,0 +1,15 @@ +{% load socialaccount %} +{% providers_media_js %} + +회원가입 +
+ +{% if user.is_authenticated %} + 로그아웃 +
+ {{ user.username }}님이 환영합니다! +{% else %} + + 구글 로그인 + +{% endif %} \ No newline at end of file diff --git a/rememB/mainapp/urls.py b/rememB/mainapp/urls.py new file mode 100644 index 0000000..09b7426 --- /dev/null +++ b/rememB/mainapp/urls.py @@ -0,0 +1,6 @@ +from django.urls import path +from . import views + +urlpatterns=[ + path('login/',views.login,name='login'), +] diff --git a/rememB/mainapp/views.py b/rememB/mainapp/views.py index 91ea44a..5c86e1a 100644 --- a/rememB/mainapp/views.py +++ b/rememB/mainapp/views.py @@ -1,3 +1,4 @@ from django.shortcuts import render -# Create your views here. +def login(request): + return render(request,'mainapp/login.html') \ No newline at end of file diff --git a/rememB/rememB/settings.py b/rememB/rememB/settings.py index d635bc3..9b5844d 100644 --- a/rememB/rememB/settings.py +++ b/rememB/rememB/settings.py @@ -40,6 +40,14 @@ 'mainapp', 'letterapp', 'balanceapp', + + #allauth + 'allauth', + 'allauth.account', + 'allauth.socialaccount', + + #provider + 'allauth.socialaccount.providers.google', ] MIDDLEWARE = [ @@ -124,3 +132,11 @@ # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + +AUTHENTICATION_BACKENDS=( + 'django.contrib.auth.backends.ModelBackend', + 'allauth.account.auth_backends.AuthenticationBackend' +) + +SITE_ID=1 +LOGIN_REDIRECT_URL='/' diff --git a/rememB/rememB/urls.py b/rememB/rememB/urls.py index 6459200..5118bba 100644 --- a/rememB/rememB/urls.py +++ b/rememB/rememB/urls.py @@ -1,21 +1,10 @@ -"""rememB URL Configuration - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/4.0/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 path, include urlpatterns = [ path('admin/', admin.site.urls), + path('balanceapp/',include('balanceapp.urls')), + path('letterapp/',include('letterapp.urls')), + path('mainapp/',include('mainapp.urls')), + path('accounts/',include('allauth.urls')), ] From 177b10382b7bdf86329aa817b4fcee874eed1050 Mon Sep 17 00:00:00 2001 From: happine2s Date: Fri, 15 Jul 2022 15:37:53 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[feat]=20=EA=B5=AC=EA=B8=80=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rememB/balanceapp/urls.py | 6 ++++++ rememB/letterapp/models.py | 2 -- rememB/letterapp/urls.py | 6 ++++++ rememB/mainapp/admin.py | 3 ++- rememB/mainapp/migrations/0001_initial.py | 21 +++++++++++++++++++++ rememB/mainapp/models.py | 3 ++- rememB/mainapp/templates/mainapp/login.html | 15 +++++++++++++++ rememB/mainapp/urls.py | 6 ++++++ rememB/mainapp/views.py | 3 ++- rememB/rememB/settings.py | 16 ++++++++++++++++ rememB/rememB/urls.py | 21 +++++---------------- 11 files changed, 81 insertions(+), 21 deletions(-) create mode 100644 rememB/balanceapp/urls.py create mode 100644 rememB/letterapp/urls.py create mode 100644 rememB/mainapp/migrations/0001_initial.py create mode 100644 rememB/mainapp/templates/mainapp/login.html create mode 100644 rememB/mainapp/urls.py diff --git a/rememB/balanceapp/urls.py b/rememB/balanceapp/urls.py new file mode 100644 index 0000000..6147f3a --- /dev/null +++ b/rememB/balanceapp/urls.py @@ -0,0 +1,6 @@ +from django.urls import path +from . import views + +urlpatterns=[ + +] diff --git a/rememB/letterapp/models.py b/rememB/letterapp/models.py index 71a8362..137941f 100644 --- a/rememB/letterapp/models.py +++ b/rememB/letterapp/models.py @@ -1,3 +1 @@ from django.db import models - -# Create your models here. diff --git a/rememB/letterapp/urls.py b/rememB/letterapp/urls.py new file mode 100644 index 0000000..6147f3a --- /dev/null +++ b/rememB/letterapp/urls.py @@ -0,0 +1,6 @@ +from django.urls import path +from . import views + +urlpatterns=[ + +] diff --git a/rememB/mainapp/admin.py b/rememB/mainapp/admin.py index 8c38f3f..39db4df 100644 --- a/rememB/mainapp/admin.py +++ b/rememB/mainapp/admin.py @@ -1,3 +1,4 @@ from django.contrib import admin +from .models import Blog -# Register your models here. +admin.site.register(Blog) \ No newline at end of file diff --git a/rememB/mainapp/migrations/0001_initial.py b/rememB/mainapp/migrations/0001_initial.py new file mode 100644 index 0000000..87541f2 --- /dev/null +++ b/rememB/mainapp/migrations/0001_initial.py @@ -0,0 +1,21 @@ +# Generated by Django 4.0.6 on 2022-07-15 13:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Blog', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('text', models.TextField()), + ], + ), + ] diff --git a/rememB/mainapp/models.py b/rememB/mainapp/models.py index 71a8362..2ddc9c2 100644 --- a/rememB/mainapp/models.py +++ b/rememB/mainapp/models.py @@ -1,3 +1,4 @@ from django.db import models -# Create your models here. +class Blog(models.Model): + text=models.TextField() \ No newline at end of file diff --git a/rememB/mainapp/templates/mainapp/login.html b/rememB/mainapp/templates/mainapp/login.html new file mode 100644 index 0000000..68f2892 --- /dev/null +++ b/rememB/mainapp/templates/mainapp/login.html @@ -0,0 +1,15 @@ +{% load socialaccount %} +{% providers_media_js %} + +회원가입 +
+ +{% if user.is_authenticated %} + 로그아웃 +
+ {{ user.username }}님이 환영합니다! +{% else %} + + 구글 로그인 + +{% endif %} \ No newline at end of file diff --git a/rememB/mainapp/urls.py b/rememB/mainapp/urls.py new file mode 100644 index 0000000..09b7426 --- /dev/null +++ b/rememB/mainapp/urls.py @@ -0,0 +1,6 @@ +from django.urls import path +from . import views + +urlpatterns=[ + path('login/',views.login,name='login'), +] diff --git a/rememB/mainapp/views.py b/rememB/mainapp/views.py index 91ea44a..5c86e1a 100644 --- a/rememB/mainapp/views.py +++ b/rememB/mainapp/views.py @@ -1,3 +1,4 @@ from django.shortcuts import render -# Create your views here. +def login(request): + return render(request,'mainapp/login.html') \ No newline at end of file diff --git a/rememB/rememB/settings.py b/rememB/rememB/settings.py index d635bc3..9b5844d 100644 --- a/rememB/rememB/settings.py +++ b/rememB/rememB/settings.py @@ -40,6 +40,14 @@ 'mainapp', 'letterapp', 'balanceapp', + + #allauth + 'allauth', + 'allauth.account', + 'allauth.socialaccount', + + #provider + 'allauth.socialaccount.providers.google', ] MIDDLEWARE = [ @@ -124,3 +132,11 @@ # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + +AUTHENTICATION_BACKENDS=( + 'django.contrib.auth.backends.ModelBackend', + 'allauth.account.auth_backends.AuthenticationBackend' +) + +SITE_ID=1 +LOGIN_REDIRECT_URL='/' diff --git a/rememB/rememB/urls.py b/rememB/rememB/urls.py index 6459200..5118bba 100644 --- a/rememB/rememB/urls.py +++ b/rememB/rememB/urls.py @@ -1,21 +1,10 @@ -"""rememB URL Configuration - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/4.0/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 path, include urlpatterns = [ path('admin/', admin.site.urls), + path('balanceapp/',include('balanceapp.urls')), + path('letterapp/',include('letterapp.urls')), + path('mainapp/',include('mainapp.urls')), + path('accounts/',include('allauth.urls')), ]