Вот мои настройки.py
Код: Выделить всё
from pathlib import Path
import os
# 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/5.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-0t^!2rh2#u8fx1k(@+#oik8l$5i^xxxxxxxxxxxxxx'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = ['127.0.0.1', 'localhost'] # Add your domain here
STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'ArchanaComputersHome',
'django_dump_die',
]
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',
'django_dump_die.middleware.DumpAndDieMiddleware',
]
ROOT_URLCONF = 'ArchanaComputers.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'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',
'django.template.context_processors.media'
],
},
},
]
WSGI_APPLICATION = 'ArchanaComputers.wsgi.application'
# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/5.0/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/5.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Asia/Kolkata'
USE_I18N = True
USE_TZ = True
Код: Выделить всё
from django.contrib import admin
from django.urls import path
from ArchanaComputersHome import views
from django.conf.urls import handler404
from django.conf import settings
from django.conf.urls.static import static
handler404 = views.page_not_found
urlpatterns = [
path('', views.index, name='home'),
path('contact', views.contact, name='contact'),
path('admission-request', views.admission_request, name='admission_request'),
]
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
admin.site.site_header = "Archana Computers"
admin.site.site_title = "Archana Computers Admin Portal"
admin.site.index_title = "Welcome to Archana Computers Admin Portal"
Код: Выделить всё
def page_not_found(request, exception=None):
"""
This function handles the 404 page not found error.
Parameters:
- request: The HTTP request object.
Returns:
- A rendered HTML template for the 404 page not found error.
Raises:
- None
"""
title = 'Page Not Found'
context = {
'title': title
}
return render(request, 'error/404.html', context)
Код: Выделить всё
{% extends "error/base/error-base.html" %}
{% load static %}
{% comment %}
This template extends the base template and includes various sections of the home page.
It also loads static files for better site accessibility.
{% endcomment %}
{% block content %}
[img]https://cdn.pixabay.com/photo/2017/03/09/12/31/error-2129569__340.jpg[/img]
class="img-fluid">
Opps! Page not found.
The page you’re looking for doesn’t exist.
[url=index.html]Go Home[/url]
{% endblock %}
Пожалуйста, проверьте и дайте мне знать, в чем проблема выдайте, если возможно.
Подробнее здесь: https://stackoverflow.com/questions/787 ... ng-in-edge