Jezzy Grey

Generation

translateFri, 17 Feb 2023

from django.db import models from django.urls import reverse import uuid class Genre(models.Model): name = models.CharField(max_length=200, help_text="Введите жанр книги") def __str__(self): return self.name class Language(models.Model): name = models.CharField(max_length=200, help_text="Язык книги") def __str__(self): return self.name class Book(models.Model): title = models.CharField(max_length=20, help_text='Введите название книги') author = models.ForeignKey('Author', on_delete=models.SET_NULL, null=True) summary = models.TextField(max_length=1000, help_text='Введите описание книги') isbn = models.CharField('ISBN', max_length=13, help_text='13 Character <a href="https://www.isbn-international' '.org/content/what-isbn">ISBN number</a>') genre = models.ManyToManyField(Genre, help_text='Выберите жанр книги') language = models.ForeignKey('Language', on_delete=models.SET_NULL, null=True) def display_genre(self): return ', '.join([genre.name for genre in self.genre.all()[:3]]) display_genre.short_description = 'Genre' def __str__(self): return self.title def get_absolute_url(self): return reverse('book-detail', args=[str(self.id)]) class BookInstance(models.Model): book = models.ForeignKey('Book', on_delete=models.SET_NULL, null=True) id = models.UUIDField(primary_key=True, default=uuid.uuid4, help_text="Unique ID for this particular book across " "whole library") imprint = models.CharField(max_length=200) due_back = models.DateField(null=True, blank=True) LOAN_STATUS = ( ('m', 'Maintenance'), ('o', 'On loan'), ('a', 'Available'), ('r', 'Reserved'), ) status = models.CharField(max_length=1, choices=LOAN_STATUS, blank=True, default='m', help_text='Book availability') class Meta: ordering = ["due_back"] def __str__(self): return '%s' % (self.book.title) class Author(models.Model): first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100) date_of_birth = models.DateField(null=True, blank=True) date_of_death = models.DateField('Died', null=True, blank=True) def get_absolute_url(self): return reverse('book-detail', args=[str(self.id)]) def __str__(self): return '%s, %s' % (self.last_name, self.first_name)

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { Console.WriteLine("First message"); Console.ReadLine(); } } }

Questions about programming?Chat with your personal AI assistant