locadm 1 year ago
commit
5c18c39a5d
39 changed files with 836 additions and 0 deletions
  1. 8 0
      .idea/.gitignore
  2. 6 0
      .idea/inspectionProfiles/profiles_settings.xml
  3. 7 0
      .idea/misc.xml
  4. 8 0
      .idea/modules.xml
  5. 10 0
      .idea/pythonProject.iml
  6. 6 0
      .idea/vcs.xml
  7. BIN
      shop/db.sqlite3
  8. 0 0
      shop/main/__init__.py
  9. 5 0
      shop/main/admin.py
  10. 6 0
      shop/main/apps.py
  11. 8 0
      shop/main/forms.py
  12. 32 0
      shop/main/migrations/0001_initial.py
  13. 141 0
      shop/main/migrations/0002_alter_product_photo_custuser.py
  14. 18 0
      shop/main/migrations/0003_rename_custuser_castuser.py
  15. 15 0
      shop/main/migrations/0004_delete_castuser.py
  16. 134 0
      shop/main/migrations/0005_custuser.py
  17. 39 0
      shop/main/migrations/0006_userprofile.py
  18. 25 0
      shop/main/migrations/0007_alter_userprofile_user_delete_custuser.py
  19. 0 0
      shop/main/migrations/__init__.py
  20. 14 0
      shop/main/models.py
  21. 0 0
      shop/main/static/css/main.css
  22. 15 0
      shop/main/templates/index.html
  23. 52 0
      shop/main/templates/layout.html
  24. 12 0
      shop/main/templates/login.html
  25. 5 0
      shop/main/templates/product_detail.html
  26. 12 0
      shop/main/templates/products.html
  27. 5 0
      shop/main/templates/profile.html
  28. 13 0
      shop/main/templates/registration.html
  29. 3 0
      shop/main/tests.py
  30. 13 0
      shop/main/urls.py
  31. 30 0
      shop/main/views.py
  32. 22 0
      shop/manage.py
  33. BIN
      shop/media/photo/71fb1fb55bbe8c9bb322ffe5bcd2a7fa-max-1000.jpg
  34. BIN
      shop/media/photo/71fb1fb55bbe8c9bb322ffe5bcd2a7fa-max-1000_pYXsFZQ.jpg
  35. 0 0
      shop/shop/__init__.py
  36. 16 0
      shop/shop/asgi.py
  37. 133 0
      shop/shop/settings.py
  38. 7 0
      shop/shop/urls.py
  39. 16 0
      shop/shop/wsgi.py

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml

+ 6 - 0
.idea/inspectionProfiles/profiles_settings.xml

@@ -0,0 +1,6 @@
+<component name="InspectionProjectProfileManager">
+  <settings>
+    <option name="USE_PROJECT_PROFILE" value="false" />
+    <version value="1.0" />
+  </settings>
+</component>

+ 7 - 0
.idea/misc.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Black">
+    <option name="sdkName" value="Python 3.12 (pythonProject)" />
+  </component>
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (pythonProject)" project-jdk-type="Python SDK" />
+</project>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/pythonProject.iml" filepath="$PROJECT_DIR$/.idea/pythonProject.iml" />
+    </modules>
+  </component>
+</project>

+ 10 - 0
.idea/pythonProject.iml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="PYTHON_MODULE" version="4">
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$">
+      <excludeFolder url="file://$MODULE_DIR$/.venv" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>

BIN
shop/db.sqlite3


+ 0 - 0
shop/main/__init__.py


+ 5 - 0
shop/main/admin.py

@@ -0,0 +1,5 @@
+from django.contrib import admin
+from .models import Product, UserProfile
+
+admin.site.register(Product)
+admin.site.register(UserProfile)

+ 6 - 0
shop/main/apps.py

@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class MainConfig(AppConfig):
+    default_auto_field = "django.db.models.BigAutoField"
+    name = "main"

+ 8 - 0
shop/main/forms.py

@@ -0,0 +1,8 @@
+from django.contrib.auth.forms import UserCreationForm
+from shop.main.models import UserProfile
+
+class RegisterUserForm(UserCreationForm):
+    class Meta:
+        model = UserProfile
+        fields = ('username', 'password1', 'password2', 'anons', 'avatar')
+

+ 32 - 0
shop/main/migrations/0001_initial.py

@@ -0,0 +1,32 @@
+# Generated by Django 5.0 on 2023-12-26 02:27
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+    initial = True
+
+    dependencies = []
+
+    operations = [
+        migrations.CreateModel(
+            name="Product",
+            fields=[
+                (
+                    "id",
+                    models.BigAutoField(
+                        auto_created=True,
+                        primary_key=True,
+                        serialize=False,
+                        verbose_name="ID",
+                    ),
+                ),
+                ("title", models.CharField(max_length=50, verbose_name="Название")),
+                (
+                    "text",
+                    models.CharField(max_length=50, verbose_name="Описание товара"),
+                ),
+                ("photo", models.ImageField(upload_to="photo/", verbose_name="Фото")),
+            ],
+        ),
+    ]

+ 141 - 0
shop/main/migrations/0002_alter_product_photo_custuser.py

@@ -0,0 +1,141 @@
+# Generated by Django 5.0 on 2023-12-26 02:53
+
+import django.contrib.auth.models
+import django.contrib.auth.validators
+import django.utils.timezone
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ("auth", "0012_alter_user_first_name_max_length"),
+        ("main", "0001_initial"),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name="product",
+            name="photo",
+            field=models.ImageField(
+                blank=True, null=True, upload_to="photo/", verbose_name="Фото"
+            ),
+        ),
+        migrations.CreateModel(
+            name="CustUser",
+            fields=[
+                (
+                    "id",
+                    models.BigAutoField(
+                        auto_created=True,
+                        primary_key=True,
+                        serialize=False,
+                        verbose_name="ID",
+                    ),
+                ),
+                ("password", models.CharField(max_length=128, verbose_name="password")),
+                (
+                    "last_login",
+                    models.DateTimeField(
+                        blank=True, null=True, verbose_name="last login"
+                    ),
+                ),
+                (
+                    "is_superuser",
+                    models.BooleanField(
+                        default=False,
+                        help_text="Designates that this user has all permissions without explicitly assigning them.",
+                        verbose_name="superuser status",
+                    ),
+                ),
+                (
+                    "username",
+                    models.CharField(
+                        error_messages={
+                            "unique": "A user with that username already exists."
+                        },
+                        help_text="Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.",
+                        max_length=150,
+                        unique=True,
+                        validators=[
+                            django.contrib.auth.validators.UnicodeUsernameValidator()
+                        ],
+                        verbose_name="username",
+                    ),
+                ),
+                (
+                    "first_name",
+                    models.CharField(
+                        blank=True, max_length=150, verbose_name="first name"
+                    ),
+                ),
+                (
+                    "last_name",
+                    models.CharField(
+                        blank=True, max_length=150, verbose_name="last name"
+                    ),
+                ),
+                (
+                    "email",
+                    models.EmailField(
+                        blank=True, max_length=254, verbose_name="email address"
+                    ),
+                ),
+                (
+                    "is_staff",
+                    models.BooleanField(
+                        default=False,
+                        help_text="Designates whether the user can log into this admin site.",
+                        verbose_name="staff status",
+                    ),
+                ),
+                (
+                    "is_active",
+                    models.BooleanField(
+                        default=True,
+                        help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.",
+                        verbose_name="active",
+                    ),
+                ),
+                (
+                    "date_joined",
+                    models.DateTimeField(
+                        default=django.utils.timezone.now, verbose_name="date joined"
+                    ),
+                ),
+                (
+                    "avatar",
+                    models.ImageField(blank=True, null=True, upload_to="avatar/"),
+                ),
+                (
+                    "groups",
+                    models.ManyToManyField(
+                        blank=True,
+                        help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
+                        related_name="user_set",
+                        related_query_name="user",
+                        to="auth.group",
+                        verbose_name="groups",
+                    ),
+                ),
+                (
+                    "user_permissions",
+                    models.ManyToManyField(
+                        blank=True,
+                        help_text="Specific permissions for this user.",
+                        related_name="user_set",
+                        related_query_name="user",
+                        to="auth.permission",
+                        verbose_name="user permissions",
+                    ),
+                ),
+            ],
+            options={
+                "verbose_name": "user",
+                "verbose_name_plural": "users",
+                "abstract": False,
+            },
+            managers=[
+                ("objects", django.contrib.auth.models.UserManager()),
+            ],
+        ),
+    ]

+ 18 - 0
shop/main/migrations/0003_rename_custuser_castuser.py

@@ -0,0 +1,18 @@
+# Generated by Django 5.0 on 2023-12-26 02:56
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ("admin", "0003_logentry_add_action_flag_choices"),
+        ("auth", "0012_alter_user_first_name_max_length"),
+        ("main", "0002_alter_product_photo_custuser"),
+    ]
+
+    operations = [
+        migrations.RenameModel(
+            old_name="CustUser",
+            new_name="CastUser",
+        ),
+    ]

+ 15 - 0
shop/main/migrations/0004_delete_castuser.py

@@ -0,0 +1,15 @@
+# Generated by Django 5.0 on 2023-12-26 02:58
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ("main", "0003_rename_custuser_castuser"),
+    ]
+
+    operations = [
+        migrations.DeleteModel(
+            name="CastUser",
+        ),
+    ]

+ 134 - 0
shop/main/migrations/0005_custuser.py

@@ -0,0 +1,134 @@
+# Generated by Django 5.0 on 2023-12-26 03:14
+
+import django.contrib.auth.models
+import django.contrib.auth.validators
+import django.utils.timezone
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ("auth", "0012_alter_user_first_name_max_length"),
+        ("main", "0004_delete_castuser"),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name="CustUser",
+            fields=[
+                (
+                    "id",
+                    models.BigAutoField(
+                        auto_created=True,
+                        primary_key=True,
+                        serialize=False,
+                        verbose_name="ID",
+                    ),
+                ),
+                ("password", models.CharField(max_length=128, verbose_name="password")),
+                (
+                    "last_login",
+                    models.DateTimeField(
+                        blank=True, null=True, verbose_name="last login"
+                    ),
+                ),
+                (
+                    "is_superuser",
+                    models.BooleanField(
+                        default=False,
+                        help_text="Designates that this user has all permissions without explicitly assigning them.",
+                        verbose_name="superuser status",
+                    ),
+                ),
+                (
+                    "username",
+                    models.CharField(
+                        error_messages={
+                            "unique": "A user with that username already exists."
+                        },
+                        help_text="Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.",
+                        max_length=150,
+                        unique=True,
+                        validators=[
+                            django.contrib.auth.validators.UnicodeUsernameValidator()
+                        ],
+                        verbose_name="username",
+                    ),
+                ),
+                (
+                    "first_name",
+                    models.CharField(
+                        blank=True, max_length=150, verbose_name="first name"
+                    ),
+                ),
+                (
+                    "last_name",
+                    models.CharField(
+                        blank=True, max_length=150, verbose_name="last name"
+                    ),
+                ),
+                (
+                    "email",
+                    models.EmailField(
+                        blank=True, max_length=254, verbose_name="email address"
+                    ),
+                ),
+                (
+                    "is_staff",
+                    models.BooleanField(
+                        default=False,
+                        help_text="Designates whether the user can log into this admin site.",
+                        verbose_name="staff status",
+                    ),
+                ),
+                (
+                    "is_active",
+                    models.BooleanField(
+                        default=True,
+                        help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.",
+                        verbose_name="active",
+                    ),
+                ),
+                (
+                    "date_joined",
+                    models.DateTimeField(
+                        default=django.utils.timezone.now, verbose_name="date joined"
+                    ),
+                ),
+                (
+                    "avatar",
+                    models.ImageField(blank=True, null=True, upload_to="avatar/"),
+                ),
+                (
+                    "groups",
+                    models.ManyToManyField(
+                        blank=True,
+                        help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
+                        related_name="user_set",
+                        related_query_name="user",
+                        to="auth.group",
+                        verbose_name="groups",
+                    ),
+                ),
+                (
+                    "user_permissions",
+                    models.ManyToManyField(
+                        blank=True,
+                        help_text="Specific permissions for this user.",
+                        related_name="user_set",
+                        related_query_name="user",
+                        to="auth.permission",
+                        verbose_name="user permissions",
+                    ),
+                ),
+            ],
+            options={
+                "verbose_name": "user",
+                "verbose_name_plural": "users",
+                "abstract": False,
+            },
+            managers=[
+                ("objects", django.contrib.auth.models.UserManager()),
+            ],
+        ),
+    ]

+ 39 - 0
shop/main/migrations/0006_userprofile.py

@@ -0,0 +1,39 @@
+# Generated by Django 5.0 on 2023-12-26 03:21
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ("main", "0005_custuser"),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name="UserProfile",
+            fields=[
+                (
+                    "id",
+                    models.BigAutoField(
+                        auto_created=True,
+                        primary_key=True,
+                        serialize=False,
+                        verbose_name="ID",
+                    ),
+                ),
+                (
+                    "anons",
+                    models.CharField(max_length=50, verbose_name="Описание профиля"),
+                ),
+                (
+                    "user",
+                    models.ForeignKey(
+                        on_delete=django.db.models.deletion.CASCADE,
+                        to=settings.AUTH_USER_MODEL,
+                    ),
+                ),
+            ],
+        ),
+    ]

+ 25 - 0
shop/main/migrations/0007_alter_userprofile_user_delete_custuser.py

@@ -0,0 +1,25 @@
+# Generated by Django 5.0 on 2023-12-26 03:24
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ("main", "0006_userprofile"),
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name="userprofile",
+            name="user",
+            field=models.OneToOneField(
+                on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
+            ),
+        ),
+        migrations.DeleteModel(
+            name="CustUser",
+        ),
+    ]

+ 0 - 0
shop/main/migrations/__init__.py


+ 14 - 0
shop/main/models.py

@@ -0,0 +1,14 @@
+
+from django.contrib.auth.models import User
+from django.db import models
+
+class Product(models.Model):
+    title = models.CharField('Название', max_length=50)
+    text = models.CharField('Описание товара',max_length=50)
+    photo = models.ImageField('Фото', upload_to='photo/', blank=True, null=True)
+
+class UserProfile(models.Model):
+    user = models.OneToOneField(User, on_delete=models.CASCADE)
+    anons = models.CharField('Описание профиля', max_length=50)
+
+

+ 0 - 0
shop/main/static/css/main.css


+ 15 - 0
shop/main/templates/index.html

@@ -0,0 +1,15 @@
+{% extends 'layout.html' %}
+
+{% block title %}Главная{% endblock %}
+
+{% block content %}
+    <h1>Главная</h1>
+    <h2>Немного о нас</h2>
+    <p>Мы очень крутая компания, которая продаёт товры на любой вкус и цвет(классные ребята, честно;3)</p>
+    <a href="{% url 'products' %}">Посмотреть все товары</a>
+    {% for product in products %}
+        <h2>{{ product.title }}</h2>
+        <img src="{{ product.photo.url }}" width="250px" height="250px">
+        <p>{{ product.text }}</p>
+`   {% endfor %}
+{% endblock %}

+ 52 - 0
shop/main/templates/layout.html

@@ -0,0 +1,52 @@
+{% load static %}
+{% load bootstrap4 %}
+
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>{% block title %}{% endblock %}</title>
+    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
+    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
+    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.min.js" integrity="sha384-BBtl+eGJRgqQAUMxJ7pMwbEyER4l1g+O15P+16Ep7Q9Q+zqX6gSbd85u4mG4QzX+" crossorigin="anonymous"></script>
+    <link rel="stylesheet" href="{% static 'css/main.css' %}">
+</head>
+<body>
+    <nav class="navbar navbar-expand-lg bg-body-tertiary">
+  <div class="container-fluid">
+    <a class="navbar-brand" href="{% url 'index' %}">Империя шапок</a>
+    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
+      <span class="navbar-toggler-icon"></span>
+    </button>
+    <div class="collapse navbar-collapse" id="navbarSupportedContent">
+      <ul class="navbar-nav me-auto mb-2 mb-lg-0">
+        <li class="nav-item">
+          <a class="nav-link active" aria-current="page" href="{% url 'index' %}">Главная</a>
+        </li>
+        <li class="nav-item">
+          <a class="nav-link" href="{% url 'products' %}">Товары</a>
+        </li>
+<!--          {% if user.is_authenticated %}-->
+            <li class="nav-item">
+              <a class="nav-link" href="{% url 'logout' %}">Выйти</a>
+            </li>
+<!--          {% else %}-->
+              <li class="nav-item">
+              <a class="nav-link" href="{% url 'registration' %}">Регистрация</a>
+            </li>
+            <li class="nav-item">
+              <a class="nav-link" href="{% url 'login' %}">Войти</a>
+            </li>
+<!--          {% endif %}-->
+
+      </ul>
+      <form class="d-flex" role="search">
+        <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
+        <button class="btn btn-outline-success" type="submit">Search</button>
+      </form>
+    </div>
+  </div>
+</nav>
+{% block content %}{% endblock %}
+</body>
+</html>

+ 12 - 0
shop/main/templates/login.html

@@ -0,0 +1,12 @@
+{% extends 'layout.html' %}
+
+{% block title %}Вход{% endblock %}
+
+{% block content %}
+    <h1>Вход</h1>
+    <form method="post">
+        {% csrf_token %}
+        {% bootstrap_form form layout='horizontal' %}
+        {% buttons submit="Вход" %}{% endbuttons %}
+    </form>
+{% endblock %}

+ 5 - 0
shop/main/templates/product_detail.html

@@ -0,0 +1,5 @@
+{% extends 'layout.html' %}
+
+{% block title %}{% endblock %}
+
+{% block content %}{% endblock %}

+ 12 - 0
shop/main/templates/products.html

@@ -0,0 +1,12 @@
+{% extends 'layout.html' %}
+
+{% block title %}Товары{% endblock %}
+
+{% block content %}
+    <h1>Все товары</h1>
+    {% for product in products %}
+        <h2>{{ product.title }}</h2>
+        <img src="{{ product.photo.url }}" width="250px" height="250px">
+        <p>{{ product.text }}</p>
+`   {% endfor %}
+{% endblock %}

+ 5 - 0
shop/main/templates/profile.html

@@ -0,0 +1,5 @@
+{% extends 'layout.html' %}
+
+{% block title %}{% endblock %}
+
+{% block content %}{% endblock %}

+ 13 - 0
shop/main/templates/registration.html

@@ -0,0 +1,13 @@
+{% extends 'layout.html' %}
+
+{% block title %}Регистрация{% endblock %}
+
+{% block content %}
+    <h1>Регистрация</h1>ъ
+    <form method="post">
+        {% csrf_token %}
+        {{ form.as_p }}
+        <input type="hidden" next="{{ next }}" value="{% url 'login' %}">
+        <button submit="Вход">Зарегаться</button>
+    </form>
+{% endblock %}

+ 3 - 0
shop/main/tests.py

@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.

+ 13 - 0
shop/main/urls.py

@@ -0,0 +1,13 @@
+from django.conf import settings
+from django.conf.urls.static import static
+from django.urls import path
+from . import views
+from .views import BBLoginView, RegistrationUserView
+
+urlpatterns = [
+    path('', views.index, name='index'),
+    path('products/', views.products, name='products'),
+    path('login/', BBLoginView.as_view, name='login'),
+    path('registration/', RegistrationUserView.as_view, name='registration'),
+    # path('logout/', Logout.as_view, name='logout')
+]+ static(settings.MEDIA_URL, document_root=settings)

+ 30 - 0
shop/main/views.py

@@ -0,0 +1,30 @@
+from django.contrib.auth import logout
+from django.contrib.auth.decorators import login_required
+from django.contrib.auth.forms import UserCreationForm
+from django.contrib.auth.views import LoginView
+from django.shortcuts import render, redirect
+from django.urls import reverse_lazy
+from django.views.generic import CreateView
+from .models import Product, UserProfile
+
+
+def index(request):
+    products = Product.objects.all()[:5]
+    return render(request, 'index.html', {'products': products})
+
+def products(request):
+    products = Product.objects.all()
+    return render(request, 'products.html', {'products': products})
+
+class BBLoginView(LoginView):
+    template_name = 'login.html'
+
+class RegistrationUserView(CreateView):
+    model = UserProfile
+    form_class = UserCreationForm
+    template_name = 'registration.html'
+    success_url = reverse_lazy('login')
+
+# class Logout(LoginView):
+#     template_name = 'index'
+

+ 22 - 0
shop/manage.py

@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+"""Django's command-line utility for administrative tasks."""
+import os
+import sys
+
+
+def main():
+    """Run administrative tasks."""
+    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "shop.settings")
+    try:
+        from django.core.management import execute_from_command_line
+    except ImportError as exc:
+        raise ImportError(
+            "Couldn't import Django. Are you sure it's installed and "
+            "available on your PYTHONPATH environment variable? Did you "
+            "forget to activate a virtual environment?"
+        ) from exc
+    execute_from_command_line(sys.argv)
+
+
+if __name__ == "__main__":
+    main()

BIN
shop/media/photo/71fb1fb55bbe8c9bb322ffe5bcd2a7fa-max-1000.jpg


BIN
shop/media/photo/71fb1fb55bbe8c9bb322ffe5bcd2a7fa-max-1000_pYXsFZQ.jpg


+ 0 - 0
shop/shop/__init__.py


+ 16 - 0
shop/shop/asgi.py

@@ -0,0 +1,16 @@
+"""
+ASGI config for shop 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/5.0/howto/deployment/asgi/
+"""
+
+import os
+
+from django.core.asgi import get_asgi_application
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "shop.settings")
+
+application = get_asgi_application()

+ 133 - 0
shop/shop/settings.py

@@ -0,0 +1,133 @@
+"""
+Django settings for shop project.
+
+Generated by 'django-admin startproject' using Django 5.0.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/5.0/topics/settings/
+
+For the full list of settings and their values, see
+https://docs.djangoproject.com/en/5.0/ref/settings/
+"""
+import os
+from pathlib import Path
+
+# 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-w@r^y1mvhktv@1%5-!idxpjagq(2ld1w5%za&c4moux@r^4wcs"
+
+# SECURITY WARNING: don't run with debug turned on in production!
+DEBUG = True
+
+ALLOWED_HOSTS = []
+
+
+# Application definition
+
+INSTALLED_APPS = [
+    "django.contrib.admin",
+    "django.contrib.auth",
+    "django.contrib.contenttypes",
+    "django.contrib.sessions",
+    "django.contrib.messages",
+    "django.contrib.staticfiles",
+    'main',
+    'bootstrap4'
+]
+
+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 = "shop.urls"
+
+TEMPLATES = [
+    {
+        "BACKEND": "django.template.backends.django.DjangoTemplates",
+        "DIRS": [],
+        "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",
+            ],
+        },
+    },
+]
+
+WSGI_APPLICATION = "shop.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 = "ru-ru"
+
+TIME_ZONE = "UTC"
+
+USE_I18N = True
+
+USE_TZ = True
+
+
+# Static files (CSS, JavaScript, Images)
+# https://docs.djangoproject.com/en/5.0/howto/static-files/
+
+STATIC_URL = "static/"
+
+# Default primary key field type
+# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
+
+DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
+
+MEDIA_URL = "/media/"
+
+MEDIA_ROOT = os.path.join(BASE_DIR, "media")
+
+LOGIN_REDIRECT_URL = "index"
+
+LOGOUT_REDIRECT_URL = "index"

+ 7 - 0
shop/shop/urls.py

@@ -0,0 +1,7 @@
+from django.contrib import admin
+from django.urls import path, include
+
+urlpatterns = [
+    path("admin/", admin.site.urls),
+    path("", include('main.urls'))
+]

+ 16 - 0
shop/shop/wsgi.py

@@ -0,0 +1,16 @@
+"""
+WSGI config for shop 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/5.0/howto/deployment/wsgi/
+"""
+
+import os
+
+from django.core.wsgi import get_wsgi_application
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "shop.settings")
+
+application = get_wsgi_application()