Skip to content
Snippets Groups Projects
Verified Commit c9c14fe2 authored by TheJoeCoder's avatar TheJoeCoder
Browse files

Add created at field, and Migrations for ordering

parent 21140b37
Branches
No related tags found
No related merge requests found
# Generated by Django 5.0.3 on 2024-06-09 09:37
import django.utils.timezone
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('library', '0027_alter_book_image'),
]
operations = [
migrations.AlterModelOptions(
name='author',
options={'ordering': ['last_name', 'first_name']},
),
migrations.AlterModelOptions(
name='publisher',
options={'ordering': ['name']},
),
migrations.AddField(
model_name='loan',
name='created_at',
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
preserve_default=False,
),
]
......@@ -190,6 +190,7 @@ class Loan(models.Model):
checked_out = models.DateTimeField()
checked_in = models.DateTimeField(null=True, blank=True)
due = models.DateTimeField()
created_at = models.DateTimeField(auto_now_add=True, editable=False)
def save(self, *args, **kwargs):
if not self.pk: # only do this for new records
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment