From adf7c0604a7ceb1d53687787ade8cbd0106658ca Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 21 Jul 2022 13:45:39 +0100 Subject: [PATCH] Add settings and URLs for authentication --- app/settings.py | 14 ++++++++++++-- app/urls.py | 8 +++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/settings.py b/app/settings.py index 670115d..00befba 100644 --- a/app/settings.py +++ b/app/settings.py @@ -10,6 +10,7 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.0/ref/settings/ """ +import os from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -37,7 +38,10 @@ INSTALLED_APPS = [ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", + "core", + "crispy_forms", ] +CRISPY_TEMPLATE_PACK = "bootstrap4" MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", @@ -54,7 +58,7 @@ ROOT_URLCONF = "app.urls" TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": [], + "DIRS": [os.path.join(BASE_DIR, "core/templates")], "APP_DIRS": True, "OPTIONS": { "context_processors": [ @@ -110,9 +114,15 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.0/howto/static-files/ -STATIC_URL = "static/" +STATIC_URL = "core/static/" + +STATICFILES_DIRS = (os.path.join(BASE_DIR, STATIC_URL),) # Default primary key field type # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" + +AUTH_USER_MODEL = "core.User" + +LOGIN_REDIRECT_URL = "/" diff --git a/app/urls.py b/app/urls.py index 5462b3e..a194d07 100644 --- a/app/urls.py +++ b/app/urls.py @@ -14,8 +14,14 @@ Including another URLconf 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 include, path + +from core.views import Home, Profile, Signup urlpatterns = [ + path("", Home.as_view(), name="home"), + path("profile/", Profile.as_view(), name="profile"), path("admin/", admin.site.urls), + path("accounts/", include("django.contrib.auth.urls")), + path("accounts/signup/", Signup.as_view(), name="signup"), ]