From 0fead1abaed0ff003aad7eb3652a9db2ec9230e0 Mon Sep 17 00:00:00 2001 From: Won Yang Date: Sun, 27 Jun 2021 19:29:25 -0500 Subject: [PATCH 1/2] adds solution --- posts_and_comments/db.sqlite3 | Bin 0 -> 143360 bytes posts_and_comments/manage.py | 22 +++ posts_and_comments/posts/__init__.py | 0 posts_and_comments/posts/admin.py | 3 + posts_and_comments/posts/apps.py | 6 + .../posts/migrations/0001_initial.py | 31 +++++ .../posts/migrations/__init__.py | 0 posts_and_comments/posts/models.py | 15 +++ .../posts/templates/posts/index.html | 11 ++ .../posts/templates/posts/post.html | 8 ++ posts_and_comments/posts/tests.py | 3 + posts_and_comments/posts/urls.py | 5 + posts_and_comments/posts/util.py | 5 + posts_and_comments/posts/views.py | 18 +++ .../posts_and_comments/__init__.py | 0 posts_and_comments/posts_and_comments/asgi.py | 16 +++ .../posts_and_comments/settings.py | 125 ++++++++++++++++++ posts_and_comments/posts_and_comments/urls.py | 19 +++ posts_and_comments/posts_and_comments/wsgi.py | 16 +++ 19 files changed, 303 insertions(+) create mode 100644 posts_and_comments/db.sqlite3 create mode 100755 posts_and_comments/manage.py create mode 100644 posts_and_comments/posts/__init__.py create mode 100644 posts_and_comments/posts/admin.py create mode 100644 posts_and_comments/posts/apps.py create mode 100644 posts_and_comments/posts/migrations/0001_initial.py create mode 100644 posts_and_comments/posts/migrations/__init__.py create mode 100644 posts_and_comments/posts/models.py create mode 100644 posts_and_comments/posts/templates/posts/index.html create mode 100644 posts_and_comments/posts/templates/posts/post.html create mode 100644 posts_and_comments/posts/tests.py create mode 100644 posts_and_comments/posts/urls.py create mode 100644 posts_and_comments/posts/util.py create mode 100644 posts_and_comments/posts/views.py create mode 100644 posts_and_comments/posts_and_comments/__init__.py create mode 100644 posts_and_comments/posts_and_comments/asgi.py create mode 100644 posts_and_comments/posts_and_comments/settings.py create mode 100644 posts_and_comments/posts_and_comments/urls.py create mode 100644 posts_and_comments/posts_and_comments/wsgi.py diff --git a/posts_and_comments/db.sqlite3 b/posts_and_comments/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..6a4c498e737d712e0e29075dce8528f144be8237 GIT binary patch literal 143360 zcmeI5du$uYeaE?cEoq8e$+En6C(Bww<6Dw66<;AAkvZnpVk%7p(9u?*L zOTw;XHHnpFsDMhdsyDQ{t|n7jIkS?}tk$q{#YQ)SWpqH-2d)Wefu6W{V)w-{QC?jY z9z502$~E&kWmi87ED>#MY;mSUc_lVhpSe`Bk0(w;ij@o`ia{E5OK&ObS2mRO8<#FA zFI-!@yn5}XaNO^5 zZGCNHZS~Tnn>@1g>`*5h)->eZVsWrC61&NWC@(Jy4<;RG*%f93YMzgc!e}PHrQn%k z#KBsH*&Yztt8WX7^6aee+Wa80e&;(j0@9)AY-{cIy=IH_$h%sra!YHSO{EKoezzo@ zq^7kyYOT3tG~!BC>*yV$uG`a%w%Xny9fNk#xKeI5YxYzcONRi%BImG z#f-M>3E9&^uWLrlDrqHWl|=GWp&e~=b66xv(JCF|E>Y>!Piw5+ZW;}pAR4NEB6Tb% zmu3YI8xGrdYUFWEB@IRF$@2|8;tx2f{$XTyJtWG-qVQnFYG1Q2Syz{NVGPBFU0Qy~ z=uq9j^zx>6W0i(8;{j1#S`uD;zf~WLBCC{j8g!|dmHH-BFK4SBX-?-O!QKs8 zy{$F2ngcg)E@}UpQ~&;KjZ8_KmPGf0UzD2}q5EETvAGnbYTMgtO)Kj)wN9QyYU)b9 zT+LK7W%d~2k|Drh4$dfC4EOeIK83hsqjm3Vq7w@yi#%3s`9wLB5q5W2i@W4>iSiG& zyo<$~(E2Gmaw6DL@7^l?I=Lq&UhoEK*S^W>$;ZpKerHE-RCLFwZ=imT#Iy7oe1ham zbZ-ixeD0jEtJ&Grjjfi}p_4Jr#ftC__>B*xABq~`V%>MrxxpLH;CSIoC0T36(A|ZM z15>A?B%F+#_DG+TJ}OnEx!6C%ej)Zu^oP+uj^2xA$G$oC@v)yCn}~cV@`1>8VulY0 zfB*=900@8p2!H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CKn^7Y7PBflEiCJyic0T2KI5C8!X009sHfrpGhTnTuDh2_v)L%*l;U*$TlH57WT z@bfdX#3qpnk)O@f$?wV9tjw6c-D%UVa!YG$4cM76Jv(KF*v&76v})DvjGXo?mQE3i z|&59r@uPcmrPF-nWWAy1-aB-I@ic7PMQ{6ThD@vqNk5d5sR6HAQjU~ zrYh+1=@TSvE)ig*vmaaT7thY(lO%m%Il#;BTW|rU&2iI)E9l#B3GDpT1hJW23{VYy z11f@@oE;~rOBp{?Vf_MaUy2p=ghVXQt@ybfD}mZ_QC8#=G1HnWvl6H^muE$ui4yBX z%1<>~vDB0bwPF^=h}~k!$JCNvfhIrH-n!q{N+J{%lZX(rrJRpTwHtDwmgzCmlMy Posts + +{% if posts_list %} + +{% else %} +

No posts yet!

+{% endif %} \ No newline at end of file diff --git a/posts_and_comments/posts/templates/posts/post.html b/posts_and_comments/posts/templates/posts/post.html new file mode 100644 index 0000000..5ecaeec --- /dev/null +++ b/posts_and_comments/posts/templates/posts/post.html @@ -0,0 +1,8 @@ +

{{current_post.title}}

+ +
    + {% comment %} in django, no need to do .all(). do 'all' instead {% endcomment %} + {% for comment in current_post.comments.all %} +
  • {{comment.body}}
  • + {% endfor %} +
\ No newline at end of file diff --git a/posts_and_comments/posts/tests.py b/posts_and_comments/posts/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/posts_and_comments/posts/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/posts_and_comments/posts/urls.py b/posts_and_comments/posts/urls.py new file mode 100644 index 0000000..fd3e418 --- /dev/null +++ b/posts_and_comments/posts/urls.py @@ -0,0 +1,5 @@ +from django.urls import path + +from . import views + +urlpatterns = [path('', views.index, name='index'), path('/', views.post, name='post')] diff --git a/posts_and_comments/posts/util.py b/posts_and_comments/posts/util.py new file mode 100644 index 0000000..8c11507 --- /dev/null +++ b/posts_and_comments/posts/util.py @@ -0,0 +1,5 @@ +from .models import Post, Comment + + +def get_post_by_id(post_id): + return Post.objects.get(id=post_id) \ No newline at end of file diff --git a/posts_and_comments/posts/views.py b/posts_and_comments/posts/views.py new file mode 100644 index 0000000..142a52f --- /dev/null +++ b/posts_and_comments/posts/views.py @@ -0,0 +1,18 @@ +from django.shortcuts import render +from django.http import HttpResponse +from .models import Post, Comment +from .util import get_post_by_id + +# Create your views here. + + +def index(request): + posts_list = Post.objects.all() + context = {'posts_list': posts_list} + return render(request, 'posts/index.html', context) + + +def post(request, id): + current_post = get_post_by_id(id) + context = {'current_post': current_post} + return render(request, 'posts/post.html', context) diff --git a/posts_and_comments/posts_and_comments/__init__.py b/posts_and_comments/posts_and_comments/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/posts_and_comments/posts_and_comments/asgi.py b/posts_and_comments/posts_and_comments/asgi.py new file mode 100644 index 0000000..6493b03 --- /dev/null +++ b/posts_and_comments/posts_and_comments/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for posts_and_comments project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'posts_and_comments.settings') + +application = get_asgi_application() diff --git a/posts_and_comments/posts_and_comments/settings.py b/posts_and_comments/posts_and_comments/settings.py new file mode 100644 index 0000000..b030806 --- /dev/null +++ b/posts_and_comments/posts_and_comments/settings.py @@ -0,0 +1,125 @@ +""" +Django settings for posts_and_comments project. + +Generated by 'django-admin startproject' using Django 3.2.4. + +For more information on this file, see +https://docs.djangoproject.com/en/3.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.2/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-wk-wev1lq1ah1qt3!69x*(2cak)d&92a7@xhov@e#rpqs30t-l' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + +# Application definition + +INSTALLED_APPS = [ + 'posts', + 'django_extensions', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +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 = 'posts_and_comments.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 = 'posts_and_comments.wsgi.application' + +# Database +# https://docs.djangoproject.com/en/3.2/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + +# Password validation +# https://docs.djangoproject.com/en/3.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/3.2/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/3.2/howto/static-files/ + +STATIC_URL = '/static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/posts_and_comments/posts_and_comments/urls.py b/posts_and_comments/posts_and_comments/urls.py new file mode 100644 index 0000000..f0b63cf --- /dev/null +++ b/posts_and_comments/posts_and_comments/urls.py @@ -0,0 +1,19 @@ +"""posts_and_comments URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/3.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, include + +urlpatterns = [path('posts/', include('posts.urls'), name='posts')] diff --git a/posts_and_comments/posts_and_comments/wsgi.py b/posts_and_comments/posts_and_comments/wsgi.py new file mode 100644 index 0000000..b70a70d --- /dev/null +++ b/posts_and_comments/posts_and_comments/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for posts_and_comments 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/3.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'posts_and_comments.settings') + +application = get_wsgi_application() From 47008909400d43053098cecf3f9ab376886a4535 Mon Sep 17 00:00:00 2001 From: Won Yang Date: Sun, 27 Jun 2021 19:36:58 -0500 Subject: [PATCH 2/2] Delete settings.py --- .../posts_and_comments/settings.py | 125 ------------------ 1 file changed, 125 deletions(-) delete mode 100644 posts_and_comments/posts_and_comments/settings.py diff --git a/posts_and_comments/posts_and_comments/settings.py b/posts_and_comments/posts_and_comments/settings.py deleted file mode 100644 index b030806..0000000 --- a/posts_and_comments/posts_and_comments/settings.py +++ /dev/null @@ -1,125 +0,0 @@ -""" -Django settings for posts_and_comments project. - -Generated by 'django-admin startproject' using Django 3.2.4. - -For more information on this file, see -https://docs.djangoproject.com/en/3.2/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/3.2/ref/settings/ -""" - -from pathlib import Path - -# Build paths inside the project like this: BASE_DIR / 'subdir'. -BASE_DIR = Path(__file__).resolve().parent.parent - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-wk-wev1lq1ah1qt3!69x*(2cak)d&92a7@xhov@e#rpqs30t-l' - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -ALLOWED_HOSTS = [] - -# Application definition - -INSTALLED_APPS = [ - 'posts', - 'django_extensions', - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', -] - -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 = 'posts_and_comments.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 = 'posts_and_comments.wsgi.application' - -# Database -# https://docs.djangoproject.com/en/3.2/ref/settings/#databases - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', - } -} - -# Password validation -# https://docs.djangoproject.com/en/3.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/3.2/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/3.2/howto/static-files/ - -STATIC_URL = '/static/' - -# Default primary key field type -# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field - -DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'