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
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class MainConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'main'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django import forms
from .models import Feedback

class FeedbackForm(forms.ModelForm):
class Meta:
model = Feedback
fields = ['name', 'email', 'message']
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.2.1 on 2025-05-11 17:49

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Feedback',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('email', models.EmailField(max_length=254)),
('message', models.TextField()),
],
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.db import models

class Feedback(models.Model):
name = models.CharField(max_length=100)
email = models.EmailField()
message = models.TextField()

def __str__(self):
return f"{self.name}: {self.message[:30]}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
body {
font-family: 'Roboto', sans-serif;
margin: 0;
padding: 0;
background-color: #f8f9fa;
color: #333;
}

header {
background-color: #e0e0e0; /* светло-серый */
padding: 20px;
text-align: center;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
margin: 0;
font-size: 2em;
}

nav a {
text-decoration: none;
color: #333;
margin: 0 10px;
font-weight: bold;
}

nav a:hover {
color: #007bff;
}

/* Main content */
main {
padding: 30px;
max-width: 800px;
margin: auto;
background-color: #fff;
box-shadow: 0 0 10px rgba(0,0,0,0.05);
border-radius: 8px;
}

/* Footer */
footer {
text-align: center;
padding: 15px;
color: #666;
font-size: 0.9em;
}

/* Form */
form {
display: flex;
flex-direction: column;
}

form input,
form textarea,
form button {
margin-bottom: 15px;
padding: 10px;
font-size: 1em;
border: 1px solid #ccc;
border-radius: 4px;
}

form button {
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
}

form button:hover {
background-color: #0056b3;
}

/* Feedback list */
ul {
list-style: none;
padding: 0;
}

li {
padding: 10px 0;
border-bottom: 1px solid #ddd;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% extends "main/base.html" %}
{% block title %}О разработке{% endblock %}
{% block content %}
<h2>О проекте</h2>
<p>Проет разработан в рамках курса по Web программированию</p>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% load static %}
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}Мой сайт{% endblock %}</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto&display=swap">
<link rel="stylesheet" href="{% static 'main/style.css' %}">
</head>
<body>
<header>
<h1>Мой Django сайт</h1>
<nav>
<a href="/">Главная</a> |
<a href="/about/">О разработке</a> |
<a href="/contact/">Обратная связь</a>
</nav>
</header>

<main>
{% block content %}{% endblock %}
</main>

<footer>
<hr>
<p>Сайтик сделан в 2025</p>
</footer>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% extends "main/base.html" %}
{% block title %}Обратная связь{% endblock %}
{% block content %}
<h2>Форма обратной связи</h2>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Отправить</button>
</form>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% extends "main/base.html" %}
{% block title %}Главная{% endblock %}
{% block content %}
<h2>Отзывы</h2>
<ul>
{% for feedback in feedbacks %}
<li><strong>{{ feedback.name }}</strong>: {{ feedback.message }}</li>
{% empty %}
<li>Пока нет отзывов.</li>
{% endfor %}
</ul>
{% 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,8 @@
from django.urls import path
from . import views

urlpatterns = [
path('', views.home, name='home'),
path('about/', views.about, name='about'),
path('contact/', views.contact, name='contact'),
]
20 changes: 20 additions & 0 deletions work/K3320/Скворцов_Иван/lab7-8/project/main/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django.shortcuts import render, redirect
from .forms import FeedbackForm
from .models import Feedback

def home(request):
feedbacks = Feedback.objects.all().order_by('-id')
return render(request, 'main/home.html', {'feedbacks': feedbacks})

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

def contact(request):
if request.method == 'POST':
form = FeedbackForm(request.POST)
if form.is_valid():
form.save()
return redirect('/')
else:
form = FeedbackForm()
return render(request, 'main/contact.html', {'form': form})
22 changes: 22 additions & 0 deletions work/K3320/Скворцов_Иван/lab7-8/project/manage.py
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', 'project.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()
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for project 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', 'project.settings')

application = get_asgi_application()
Loading