Populate models

parent 036c60a4
# Generated by Django 4.1.6 on 2023-03-28 11:38
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='books',
name='blurb',
field=models.TextField(default='', max_length=400),
),
]
# Generated by Django 4.1.6 on 2023-03-28 11:41
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0002_alter_books_blurb'),
]
operations = [
migrations.AlterField(
model_name='books',
name='isbn',
field=models.PositiveBigIntegerField(validators=[django.core.validators.MinLengthValidator(13), django.core.validators.MaxLengthValidator(13)]),
),
]
# Generated by Django 4.1.6 on 2023-03-28 11:46
import django.core.validators
from django.db import migrations, models
import re
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0003_alter_books_isbn'),
]
operations = [
migrations.AlterField(
model_name='books',
name='isbn',
field=models.CharField(default='0000000000000', max_length=13, validators=[django.core.validators.RegexValidator(re.compile('^\\d+(?:\\d+)*\\Z'), code='invalid', message=None), django.core.validators.MinLengthValidator(13)]),
),
]
from django.db import models from django.db import models
from django.core.validators import MinValueValidator, MaxValueValidator from django.core.validators import MinValueValidator, MaxValueValidator, MinLengthValidator, MaxLengthValidator, int_list_validator
import datetime import datetime
class Author(models.Model): class Author(models.Model):
...@@ -19,8 +19,8 @@ class Books(models.Model): ...@@ -19,8 +19,8 @@ class Books(models.Model):
author = models.ForeignKey(Author, on_delete = models.PROTECT) author = models.ForeignKey(Author, on_delete = models.PROTECT)
publisher = models.CharField(max_length = 200, default = default_string) publisher = models.CharField(max_length = 200, default = default_string)
year_published = models.IntegerField(validators = [MaxValueValidator(datetime.datetime.now().year)], default = datetime.datetime.now().year) year_published = models.IntegerField(validators = [MaxValueValidator(datetime.datetime.now().year)], default = datetime.datetime.now().year)
isbn = models.IntegerField(validators = [MinValueValidator(1), MaxValueValidator(9999999999999)], default = 0) isbn = models.CharField(max_length=13, validators=[int_list_validator(sep=''),MinLengthValidator(13),], default='0000000000000')
blurb = models.TextField(max_length = 200, default = default_string) blurb = models.TextField(max_length = 400, default = default_string)
def __str__(self): def __str__(self):
return '{}'.format(self.title) return '{}'.format(self.title)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment