Add project files

This commit is contained in:
Nika
2025-12-29 04:26:49 +03:00
parent ace5cf9e70
commit 32e797bce7
26 changed files with 602 additions and 0 deletions
View File
+16
View File
@@ -0,0 +1,16 @@
"""
ASGI config for config 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/6.0/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
application = get_asgi_application()
+90
View File
@@ -0,0 +1,90 @@
from pathlib import Path
import os
from dotenv import load_dotenv
# 1. Загружаем переменные из .env
load_dotenv()
BASE_DIR = Path(__file__).resolve().parent.parent
# 2. Настройки безопасности
SECRET_KEY = os.getenv('SECRET_KEY', 'django-insecure-default-key-if-env-missing')
DEBUG = os.getenv('DEBUG') == 'True'
ALLOWED_HOSTS = []
# 3. ПОДКЛЮЧЕННЫЕ ПРИЛОЖЕНИЯ (Этого не хватало!)
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'bot',
]
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 = 'config.urls'
# 4. НАСТРОЙКИ ШАБЛОНОВ (Нужны для вашего HTML-DSL)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True, # Важно: True, чтобы искать шаблоны внутри папки bot/templates
'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 = 'config.wsgi.application'
# 5. База данных (SQLite по умолчанию)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# 6. Язык и локализация (Ваши настройки)
LANGUAGE_CODE = 'ru'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
LANGUAGES = [
('ru', 'Russian'),
('en', 'English'),
('fr', 'French'),
('de', 'German'),
]
LOCALE_PATHS = [
BASE_DIR / 'locale',
]
STATIC_URL = 'static/'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# 7. Токен бота
TELEGRAM_TOKEN = os.getenv('TELEGRAM_TOKEN')
# Проверка, чтобы не запускать без токена
if not TELEGRAM_TOKEN:
print("WARNING: TELEGRAM_TOKEN не найден в .env, бот не запустится!")
+22
View File
@@ -0,0 +1,22 @@
"""
URL configuration for config project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/6.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
urlpatterns = [
path('admin/', admin.site.urls),
]
+16
View File
@@ -0,0 +1,16 @@
"""
WSGI config for config 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/6.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
application = get_wsgi_application()