This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| build.gradle.kts (Project): | |
| plugins { | |
| alias(libs.plugins.android.application) apply false | |
| kotlin("plugin.compose") version "2.0.21" apply false // !!! | |
| } | |
| ================================================================================================================== | |
| build.gradle.kts (Module:app): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <androidx.coordinatorlayout.widget.CoordinatorLayout | |
| xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:background="#0A0A0F"> | |
| <!-- Декоративне коло вгорі --> | |
| <View |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SERVER SIDE: | |
| #include <sys/socket.h> | |
| #include <netinet/in.h> | |
| #include <arpa/inet.h> | |
| #include <unistd.h> | |
| #include <iostream> | |
| #include <vector> | |
| #include <string> | |
| #include <cstring> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CLIENT SIDE: | |
| #include <iostream> | |
| #include <cstring> | |
| #include <cstdlib> | |
| #include <unistd.h> | |
| #include <arpa/inet.h> | |
| #include <sys/socket.h> | |
| using namespace std; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import datetime | |
| from django.shortcuts import render | |
| from django.http import HttpRequest | |
| from django.db.models import Avg, Count, Sum, Max, Min, F, Q | |
| from app.models import Author, Book | |
| # ============================================================================= | |
| # CRUD ДЛЯ AUTHOR (це було вже :) | |
| # ============================================================================= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| на всякий випадок: | |
| env\Scripts\activate | |
| python manage.py shell | |
| from app.views import author_filter_advanced, author_order_by, author_in, author_startswith, author_bulk_create, author_values, author_first_last, author_exists, author_union | |
| ... | |
| # ── РОЗШИРЕНІ ЗАПИТИ ────────────────────────────────────────────────────────── |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import datetime | |
| from django.shortcuts import render | |
| from django.http import HttpRequest | |
| from app.models import Author | |
| # ── CREATE ──────────────────────────────────────────────────────────────────── | |
| def author_create_method1(request): | |
| """Вставка автора через objects.create() - один рядок, одразу зберігає в БД""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.core.management.base import BaseCommand | |
| from django.apps import apps | |
| from app.models import Author, Book | |
| class Command(BaseCommand): | |
| help = 'Наповнює базу даних початковими авторами та книгами' | |
| def handle(self, *args, **options): | |
| self.stdout.write(self.style.SUCCESS('Ласкаво просимо в кастомний шелл!')) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db import models | |
| from django.db.models import Q, F # для складних запитів, наприклад, для перевірки умов у CheckConstraint | |
| # Q використовується для створення складних умов, F використовується для посилання на інші поля в моделі при створенні обмежень або запитів | |
| # https://docs.djangoproject.com/en/6.0/ref/models/querysets/#django.db.models.Q | |
| # https://docs.djangoproject.com/en/6.0/ref/models/expressions/#django.db.models.F | |
| class Author(models.Model): | |
| name = models.CharField(max_length=100, unique=True) | |
| birth_year = models.IntegerField(null=True, blank=True) | |
| rating = models.DecimalField(max_digits=3, decimal_places=1, default=5.0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| ..... | |
| DATABASES = { | |
| 'default': { | |
| 'ENGINE': os.getenv('DB_ENGINE'), |