Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.contrib import admin
from .models import Product, Order

admin.site.register(Product)
admin.site.register(Order)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class CoreConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'core'
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django import forms
from .models import Product, Order

class OrderForm(forms.ModelForm):
class Meta:
model = Order
fields = ['product', 'full_name', 'email', 'telegram', 'phone']

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['product'].queryset = Product.objects.all()
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by Django 5.2.1 on 2025-05-12 21:59

import django.db.models.deletion
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')),
('name', models.CharField(max_length=100)),
('description', models.TextField()),
('price', models.DecimalField(decimal_places=2, max_digits=10)),
('image', models.ImageField(upload_to='products/')),
],
),
migrations.CreateModel(
name='Order',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('full_name', models.CharField(max_length=100)),
('email', models.EmailField(max_length=254)),
('telegram', models.CharField(max_length=100)),
('phone', models.CharField(max_length=20)),
('created_at', models.DateTimeField(auto_now_add=True)),
('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.product')),
],
),
]
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django.db import models

class Product(models.Model):
name = models.CharField(max_length=100)
description = models.TextField()
price = models.DecimalField(max_digits=10, decimal_places=2)
image = models.ImageField(upload_to='products/')

def __str__(self):
return self.name

class Order(models.Model):
product = models.ForeignKey(Product, on_delete=models.CASCADE)
full_name = models.CharField(max_length=100)
email = models.EmailField()
telegram = models.CharField(max_length=100)
phone = models.CharField(max_length=20)
created_at = models.DateTimeField(auto_now_add=True)

def __str__(self):
return f"Order #{self.id} - {self.product.name}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% extends 'core/base.html' %}

{% block title %}О бренде{% endblock %}

{% block content %}
<h2 class="mb-4">О бренде</h2>
<div class="row">
<div class="col-md-8 mx-auto">
<p>NO WOE | NO WORDS ONLY EMOTION - это молодой развивающийся бренд вдохновленный стилем уличной одежды и эмоциональной составляющей каждого из нас. Мы создаём вещи которые цепляют взгляды.</p>
<p>Доставка проходит через СДЕК за счёт покупателя</p>
<p>Срок изготовления до 14 дней</p>
</div>
</div>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NO WOE | {% block title %}{% endblock %}</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<header class="bg-dark text-white p-3">
<div class="container">
<div class="d-flex justify-content-between align-items-center">
<h1>NO WOE</h1>
<nav>
<a href="{% url 'index' %}" class="text-white mx-2">Главная</a>
<a href="{% url 'about' %}" class="text-white mx-2">О бренде</a>
<a href="{% url 'contact' %}" class="text-white mx-2">Предзаказ</a>
</nav>
</div>
</div>
</header>

<main class="container my-4">
{% block content %}
{% endblock %}
</main>

<footer class="bg-dark text-white p-3 mt-4">
<div class="container text-center">
<p>NO WOE | NO WORDS ONLY EMOTION © {% now "Y" %}</p>
</div>
</footer>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% extends 'core/base.html' %}

{% block title %}Предзаказ{% endblock %}

{% block content %}
<h2 class="mb-4">Форма предзаказа</h2>
<div class="row">
<div class="col-md-6 mx-auto">
{% if success %}
<div class="alert alert-success">
Спасибо за ваш предзаказ! Мы свяжемся с вами в ближайшее время.
</div>
{% else %}
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit" class="btn btn-dark">Отправить</button>
</form>
{% endif %}
</div>
</div>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% extends 'core/base.html' %}

{% block title %}Главная{% endblock %}

{% block content %}
<h2 class="mb-4">Наши товары</h2>
<div class="row">
{% for product in products %}
<div class="col-md-4 mb-4">
<div class="card h-100">
<img src="{{ product.image.url }}" class="card-img-top" alt="{{ product.name }}">
<div class="card-body">
<h5 class="card-title">{{ product.name }}</h5>
<p class="card-text">{{ product.description }}</p>
<p class="card-text"><strong>{{ product.price }} руб.</strong></p>
<a href="{% url 'contact' %}?product={{ product.id }}" class="btn btn-dark">Предзаказ</a>
</div>
</div>
</div>
{% endfor %}
</div>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.urls import path
from . import views

urlpatterns = [
path('', views.index, name='index'),
path('about/', views.about, name='about'),
path('contact/', views.contact, name='contact'),
]

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django.shortcuts import render
from .models import Product
from .forms import OrderForm

def index(request):
products = Product.objects.all()
return render(request, 'core/index.html', {'products': products})

def about(request):
return render(request, 'core/about.html')

def contact(request):
if request.method == 'POST':
form = OrderForm(request.POST)
if form.is_valid():
form.save()
return render(request, 'core/contact.html', {'success': True})
else:
form = OrderForm()

return render(request, 'core/contact.html', {'form': form})
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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', 'nowoe.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()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for nowoe 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.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'nowoe.settings')

application = get_asgi_application()
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
"""
Django settings for nowoe project.

Generated by 'django-admin startproject' using Django 5.2.1.

For more information on this file, see
https://docs.djangoproject.com/en/5.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.2/ref/settings/
"""

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.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-&95-t-)j3kaf-^d$y($y_kc%j%_!_j&$ybhgmz*k60&d491n9e'

# 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',
'core',
]

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 = 'nowoe.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'nowoe.wsgi.application'


# Database
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}


# Password validation
# https://docs.djangoproject.com/en/5.2/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.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.2/howto/static-files/

STATIC_URL = 'static/'

# Default primary key field type
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
Loading