18 | | I can not capture 'Message' with `LoginView`. |
| 20 | I can not capture 'Message' with LoginView. |
| 21 | |
| 22 | project urls: |
| 23 | {{{#!py |
| 24 | |
| 25 | urlpatterns = [ |
| 26 | |
| 27 | path('admin/', admin.site.urls), |
| 28 | path(, include('django.contrib.auth.urls')), |
| 29 | path(, include('base.urls')), |
| 30 | |
| 31 | ] |
| 32 | }}} |
| 33 | |
| 34 | the base apps urls: |
| 35 | {{{#!py |
| 36 | # app_name = 'base' |
| 37 | |
| 38 | urlpatterns = [ |
| 39 | |
| 40 | path(, views.Home.as_view(), name='home'), |
| 41 | path('room/<int:pk>/', views.Room.as_view(), name='room'), |
| 42 | path('create-room/', views.CreateRoom.as_view(), name='create-room'), |
| 43 | path('update-room/<int:pk>/', views.UpdateRoom.as_view(model=Room), name='update-room'), |
| 44 | path('delete-room/<int:pk>/', views.DeleteRoom.as_view(model=Room), name='delete-room'), |
| 45 | path('login/', views.Login.as_view(), name='login') |
| 46 | |
| 47 | ] |
| 48 | }}} |
| 49 | |
| 50 | settings.py: |
| 51 | {{{#!py |
| 52 | |
| 53 | INSTALLED_APPS = [ |
| 54 | |
| 55 | # Default django apps |
| 56 | 'django.contrib.admin', |
| 57 | 'django.contrib.auth', |
| 58 | 'django.contrib.contenttypes', |
| 59 | 'django.contrib.sessions', |
| 60 | 'django.contrib.messages', |
| 61 | 'django.contrib.staticfiles', |
| 62 | |
| 63 | # My custom apps |
| 64 | 'base.apps.BaseConfig', |
| 65 | |
| 66 | ] |
| 67 | |
| 68 | MIDDLEWARE = [ |
| 69 | |
| 70 | 'django.middleware.security.SecurityMiddleware', |
| 71 | 'django.contrib.sessions.middleware.SessionMiddleware', |
| 72 | 'django.middleware.common.CommonMiddleware', |
| 73 | 'django.middleware.csrf.CsrfViewMiddleware', |
| 74 | 'django.contrib.auth.middleware.AuthenticationMiddleware', |
| 75 | 'django.contrib.messages.middleware.MessageMiddleware', |
| 76 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
| 77 | |
| 78 | ] |
| 79 | |
| 80 | ROOT_URLCONF = 'studybud.urls' |
| 81 | |
| 82 | TEMPLATES = [ |
| 83 | |
| 84 | { |
| 85 | |
| 86 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', |
| 87 | 'DIRS': [BASE_DIR / 'templates'] |
| 88 | , |
| 89 | 'APP_DIRS': True, |
| 90 | 'OPTIONS': { |
| 91 | |
| 92 | 'context_processors': [ |
| 93 | |
| 94 | 'django.template.context_processors.debug', |
| 95 | 'django.template.context_processors.request', |
| 96 | 'django.contrib.auth.context_processors.auth', |
| 97 | 'django.contrib.messages.context_processors.messages', |
| 98 | |
| 99 | ], |
| 100 | |
| 101 | }, |
| 102 | |
| 103 | }, |
| 104 | |
| 105 | ] |
| 106 | |
| 107 | WSGI_APPLICATION = 'studybud.wsgi.application' |
| 108 | |
| 109 | # Database |
| 110 | # https://docs.djangoproject.com/en/4.0/ref/settings/#databases |
| 111 | |
| 112 | DATABASES = { |
| 113 | |
| 114 | 'default': { |
| 115 | |
| 116 | 'ENGINE': 'django.db.backends.sqlite3', |
| 117 | 'NAME': BASE_DIR / 'db.sqlite3', |
| 118 | |
| 119 | } |
| 120 | |
| 121 | } |
| 122 | |
| 123 | # Password validation |
| 124 | # https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators |
| 125 | |
| 126 | AUTH_PASSWORD_VALIDATORS = [ |
| 127 | |
| 128 | { |
| 129 | |
| 130 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', |
| 131 | |
| 132 | }, |
| 133 | { |
| 134 | |
| 135 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', |
| 136 | |
| 137 | }, |
| 138 | { |
| 139 | |
| 140 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', |
| 141 | |
| 142 | }, |
| 143 | { |
| 144 | |
| 145 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', |
| 146 | |
| 147 | }, |
| 148 | |
| 149 | ] |
| 150 | |
| 151 | # Internationalization |
| 152 | # https://docs.djangoproject.com/en/4.0/topics/i18n/ |
| 153 | |
| 154 | LANGUAGE_CODE = 'en-us' |
| 155 | |
| 156 | TIME_ZONE = 'UTC' |
| 157 | |
| 158 | USE_I18N = True |
| 159 | |
| 160 | USE_TZ = True |
| 161 | |
| 162 | # Static files (CSS, JavaScript, Images) |
| 163 | # https://docs.djangoproject.com/en/4.0/howto/static-files/ |
| 164 | |
| 165 | STATIC_URL = 'static/' |
| 166 | |
| 167 | # Default primary key field type |
| 168 | # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field |
| 169 | |
| 170 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' |
| 171 | |
| 172 | # Login redirect |
| 173 | LOGIN_REDIRECT_URL = 'home' |
| 174 | LOGIN_URL = 'login' |
| 175 | }}} |