Fix os import and add media settings 6
This commit is contained in:
Binary file not shown.
@@ -80,12 +80,6 @@ DATABASES = {
|
||||
}
|
||||
}
|
||||
|
||||
# добавил от жемени из за нжинкса
|
||||
|
||||
CSRF_TRUSTED_ORIGINS = [
|
||||
"http://192.168.1.57:8080",
|
||||
"https://shop.tertelius.space", # Сразу добавь на будущее
|
||||
]
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators
|
||||
@@ -109,9 +103,11 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/5.2/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
# LANGUAGE_CODE = 'en-us'
|
||||
LANGUAGE_CODE = 'ru-ru'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
# TIME_ZONE = 'UTC'
|
||||
TIME_ZONE = 'Europe/Moscow'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
@@ -132,3 +128,10 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
# добавил от жемени из за нжинкса
|
||||
|
||||
CSRF_TRUSTED_ORIGINS = [
|
||||
"http://192.168.1.57:8080",
|
||||
"https://shop.tertelius.space", # Сразу добавь на будущее
|
||||
]
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
echo "Collecting static files..."
|
||||
python manage.py collectstatic --noinput
|
||||
|
||||
# Применяем миграции базы данных
|
||||
echo "Applying database migrations..."
|
||||
python manage.py migrate --noinput
|
||||
|
||||
# Запускаем основную команду (Gunicorn)
|
||||
echo "Starting Gunicorn..."
|
||||
exec "$@"
|
||||
Binary file not shown.
Binary file not shown.
@@ -3,4 +3,6 @@ from .models import Product
|
||||
|
||||
@admin.register(Product)
|
||||
class ProductAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'price', 'weight')
|
||||
# Убираем 'weight', добавляем 'image'
|
||||
list_display = ('name', 'price', 'image')
|
||||
search_fields = ('name',)
|
||||
@@ -0,0 +1,33 @@
|
||||
# Generated by Django 5.2.10 on 2026-01-21 02:01
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('products', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='product',
|
||||
name='weight',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='product',
|
||||
name='description',
|
||||
field=models.TextField(default=1, verbose_name='Описание'),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='product',
|
||||
name='image',
|
||||
field=models.ImageField(blank=True, null=True, upload_to='products/', verbose_name='Изображение'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='product',
|
||||
name='name',
|
||||
field=models.CharField(max_length=200, verbose_name='Название'),
|
||||
),
|
||||
]
|
||||
@@ -1,9 +1,10 @@
|
||||
from django.db import models
|
||||
|
||||
class Product(models.Model):
|
||||
name = models.CharField(max_length=255, verbose_name="Название")
|
||||
name = models.CharField(max_length=200, verbose_name="Название")
|
||||
description = models.TextField(verbose_name="Описание")
|
||||
price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="Цена")
|
||||
weight = models.FloatField(verbose_name="Вес (кг)")
|
||||
image = models.ImageField(upload_to='products/', null=True, blank=True, verbose_name="Изображение")
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@@ -1,8 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Мой Магазин</title>
|
||||
<style>
|
||||
body { font-family: sans-serif; margin: 40px; }
|
||||
.product { border-bottom: 1px solid #ccc; padding: 10px; margin-bottom: 10px; }
|
||||
.admin-link { background: #417690; color: white; padding: 10px; text-decoration: none; border-radius: 4px; }
|
||||
img { max-width: 200px; height: auto; display: block; margin-top: 10px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Список товаров</h1>
|
||||
<ul>
|
||||
{% for p in products %}
|
||||
<li>{{ p.name }} — Цена: {{ p.price }} руб. ({{ p.weight }} кг)</li>
|
||||
<a href="/admin/" class="admin-link">Перейти в панель админа</a>
|
||||
<hr>
|
||||
|
||||
{% for product in products %}
|
||||
<div class="product">
|
||||
<h2>{{ product.name }}</h2>
|
||||
<p>{{ product.description }}</p>
|
||||
<p><strong>Цена: {{ product.price }} руб.</strong></p>
|
||||
{% if product.image %}
|
||||
<img src="{{ product.image.url }}" alt="{{ product.name }}">
|
||||
{% else %}
|
||||
<p>Нет изображения</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% empty %}
|
||||
<li>Товаров пока нет.</li>
|
||||
<p>Товаров пока нет.</p>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
BIN
requirements.txt
BIN
requirements.txt
Binary file not shown.
Reference in New Issue
Block a user