From 2c5704c4d91769132522fcd8b86bc01302511d2d Mon Sep 17 00:00:00 2001 From: Dylan Sechet <dylan.sechet82@gmail.com> Date: Sat, 6 Feb 2021 14:57:25 +0100 Subject: [PATCH] Ordered student profiles by last modification date in admin --- profiles/admin.py | 1 + .../migrations/0015_student_updated_date.py | 18 ++++++++++++++++++ profiles/models.py | 2 ++ 3 files changed, 21 insertions(+) create mode 100644 profiles/migrations/0015_student_updated_date.py diff --git a/profiles/admin.py b/profiles/admin.py index f7fc71a..6aefa1a 100644 --- a/profiles/admin.py +++ b/profiles/admin.py @@ -50,4 +50,5 @@ class StudentAdmin(ProfileAdminMixin, admin.ModelAdmin,ExportCsvMixin): list_filter = (('school',MultiSelectFieldListFilter), 'year', 'registration__validated') class Meta: # noqa model = Student + ordering = ['updated_date'] actions = ["export_as_csv"] \ No newline at end of file diff --git a/profiles/migrations/0015_student_updated_date.py b/profiles/migrations/0015_student_updated_date.py new file mode 100644 index 0000000..4e672b5 --- /dev/null +++ b/profiles/migrations/0015_student_updated_date.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2 on 2021-01-15 17:06 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('profiles', '0014_auto_20201116_1118'), + ] + + operations = [ + migrations.AddField( + model_name='student', + name='updated_date', + field=models.DateTimeField(auto_now=True), + ), + ] diff --git a/profiles/models.py b/profiles/models.py index 20952a3..4c9d912 100644 --- a/profiles/models.py +++ b/profiles/models.py @@ -38,6 +38,8 @@ class Student(ProfileMixin, models.Model): detail_view_name = 'api:student-detail' + updated_date = models.DateTimeField(auto_now=True) + user = models.OneToOneField( 'users.User', on_delete=models.CASCADE, -- GitLab