Створити простий багатороздільний вебсайт компанії з чіткою структурою URL.
| Розділ | Базова адреса |
|---|
| models.py: | |
| import os | |
| from django.db import models | |
| from django.core.validators import MinLengthValidator | |
| from datetime import datetime | |
| def resume_upload_path(instance, filename): | |
| """Генерує шлях для резюме""" |
| settings.py: | |
| import os # !!! | |
| import posixpath | |
| from pathlib import Path | |
| BASE_DIR = Path(__file__).resolve().parent.parent | |
| SECRET_KEY = '545bb8a0-f016-4d1b-8b4f-22bd108e577a' |
| contact.html: | |
| {% extends "app/layout.html" %} | |
| {% load static %} | |
| {% block content %} | |
| <link rel="stylesheet" href="{% static 'app/css/styles.css' %}"> | |
| <div class="container mt-5"> | |
| <h2>{{ title|default:"Відправка резюме" }}</h2> |
| from django import forms | |
| from django.core.validators import MinLengthValidator, RegexValidator | |
| from datetime import date | |
| # звісно, існують і бібліотеки для валідації форм, наприклад django-crispy-forms + crispy-bootstrap5 | |
| # pydantic (з Django Ninja або самостійно), або django-bootstrap5 | |
| # https://django-crispy-forms.readthedocs.io/en/latest/ | |
| # встановлення: pip install django-crispy-forms crispy-bootstrap5 | |
| # https://pydantic.dev/docs/validation/latest/get-started/ |
| contact.html: | |
| {% extends "app/layout.html" %} | |
| {% load static %} | |
| {% block content %} | |
| <link rel="stylesheet" href="{% static 'app/css/styles.css' %}"> | |
| <div class="container mt-5"> |
| {% extends "app/layout.html" %} | |
| {% block content %} | |
| <div class="container mt-5"> | |
| <h2>{{ title|default:"Заявка на консультацію" }}</h2> | |
| <p class="text-muted">Різні способи рендерингу Django форм</p> | |
| <hr> | |
| {% if messages %} | |
| {% for msg in messages %} |
| Forms / app / templates / app / contact.html: | |
| {% extends "app/layout.html" %} | |
| {% load static %} | |
| {% block content %} | |
| <link rel="stylesheet" href="{% static 'app/css/styles.css' %}"> | |
| <div class="container mt-5"> |
| using System.Text; | |
| using Newtonsoft.Json; // dotnet add package Newtonsoft.Json | |
| class Program | |
| { | |
| private const string AddCitiesUrl = "http://sunmeat.mywebcommunity.org/upload.php"; | |
| private const string GetCitiesUrl = "http://sunmeat.mywebcommunity.org/get_cities.php"; | |
| private static readonly HttpClient client = new(); | |
| static async Task Main() |
| # app / views.py: | |
| from datetime import datetime | |
| from django.shortcuts import render | |
| from django.http import HttpRequest | |
| from app.models import Author | |
| def home(request): | |
| message = None # повідомлення про успіх/помилку |