Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.db import models
- from django.contrib.auth.models import User
- class Autor(models.Model):
- imie = models.CharField(max_length=100, verbose_name="Imię")
- nazwisko = models.CharField(max_length=100)
- class Meta:
- ordering = ['nazwisko', 'imie']
- verbose_name_plural = 'Autorzy'
- def __str__(self):
- return "{}, {}".format(self.nazwisko, self.imie)
- class Wydawnictwo(models.Model):
- nazwa = models.CharField(max_length=200)
- class Meta:
- ordering = ['nazwa']
- verbose_name_plural = 'Wydawnictwa'
- def __str__(self):
- return self.nazwa
- class Wypozyczajacy(models.Model):
- imie = models.CharField(max_length=100, verbose_name='Imię')
- nazwisko = models.CharField(max_length=100)
- telefon = models.CharField(max_length=50, blank=True, null=True)
- email = models.EmailField(blank=True, null=True, verbose_name='E-mail')
- class Meta:
- ordering = ['nazwisko', 'imie']
- verbose_name_plural = 'Wypożyczający'
- def __str__(self):
- return "{}, {}".format(self.nazwisko, self.imie)
- class Ksiazka(models.Model):
- tytul = models.CharField(max_length=200, verbose_name='Tytuł', help_text='pole wymagane')
- # PROBLEM
- autor = models.ForeignKey(Autor)
- wydawnictwo = models.ForeignKey(Wydawnictwo)
- wydanie = models.CharField(max_length=10, null=True, blank=True)
- rok_wydania = models.CharField(max_length=10, null=True, blank=True)
- wypozyczajacy = models.ForeignKey(Wypozyczajacy, null=True, blank=True)
- data_wypozyczenia = models.DateField(null=True, blank=True)
- data_wpisu = models.DateTimeField(auto_now_add=True)
- ostatnia_aktualizacja = models.DateTimeField(auto_now=True)
- STATUS = (
- ('d', 'w domu'),
- ('w', 'wypożyczona')
- )
- status = models.CharField(max_length=1, choices=STATUS, default='d')
- class Meta:
- ordering = ['tytul']
- verbose_name_plural = 'Książki'
- def __str__(self):
- return self.tytul
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement