From 6748a71cbdb63dc920d3c2536d134eec6b8b1a94 Mon Sep 17 00:00:00 2001 From: yukitya-1811 Date: Wed, 19 Jun 2024 22:49:36 +0530 Subject: [PATCH 1/2] Change timezone.now to timezone.localtime --- corpus/accounts/migrations/0001_initial.py | 2 +- corpus/accounts/models.py | 2 +- corpus/virtual_expo/member_views.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/corpus/accounts/migrations/0001_initial.py b/corpus/accounts/migrations/0001_initial.py index db5ae72a..56a03946 100644 --- a/corpus/accounts/migrations/0001_initial.py +++ b/corpus/accounts/migrations/0001_initial.py @@ -71,7 +71,7 @@ class Migration(migrations.Migration): ( "date_joined", models.DateTimeField( - default=django.utils.timezone.now, verbose_name="date joined" + default=django.utils.timezone.localtime, verbose_name="date joined" ), ), ("phone_no", models.CharField(max_length=13, unique=True)), diff --git a/corpus/accounts/models.py b/corpus/accounts/models.py index c6abcade..9c17762e 100644 --- a/corpus/accounts/models.py +++ b/corpus/accounts/models.py @@ -140,7 +140,7 @@ class ExecutiveMember(models.Model): ) is_nep = models.BooleanField(default=False, verbose_name="Is NEP Member?") date_joined = models.DateTimeField( - default=timezone.now(), verbose_name="Date Joined" + default=timezone.localtime(), verbose_name="Date Joined" ) def save(self, *args, **kwargs): diff --git a/corpus/virtual_expo/member_views.py b/corpus/virtual_expo/member_views.py index f29d8340..cd2466a0 100644 --- a/corpus/virtual_expo/member_views.py +++ b/corpus/virtual_expo/member_views.py @@ -43,7 +43,7 @@ def new_report(request): form = ReportForm(request.POST, request.FILES) if form.is_valid(): report = form.save(commit=False) - report.created_at = timezone.now() + report.created_at = timezone.localtime() report.save() ReportMember.objects.create(report=report, member=request.exec_member) @@ -148,7 +148,7 @@ def approver_dashboard(request): report = Report.objects.get(pk=report_id) if report.approver == request.exec_member: report.approved = True - report.approved_at = timezone.now() + report.approved_at = timezone.localtime() report.save() messages.success(request, "Report marked as approved!") return redirect("virtual_expo_members_approver_dashboard") From 7ef39df9b7f83806dedaeb6fd4368b7d7bee20c4 Mon Sep 17 00:00:00 2001 From: yukitya-1811 Date: Sat, 29 Jun 2024 12:57:58 +0530 Subject: [PATCH 2/2] Create new migrations to make change --- corpus/accounts/migrations/0001_initial.py | 2 +- .../0006_alter_executivemember_date_joined.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 corpus/accounts/migrations/0006_alter_executivemember_date_joined.py diff --git a/corpus/accounts/migrations/0001_initial.py b/corpus/accounts/migrations/0001_initial.py index 56a03946..db5ae72a 100644 --- a/corpus/accounts/migrations/0001_initial.py +++ b/corpus/accounts/migrations/0001_initial.py @@ -71,7 +71,7 @@ class Migration(migrations.Migration): ( "date_joined", models.DateTimeField( - default=django.utils.timezone.localtime, verbose_name="date joined" + default=django.utils.timezone.now, verbose_name="date joined" ), ), ("phone_no", models.CharField(max_length=13, unique=True)), diff --git a/corpus/accounts/migrations/0006_alter_executivemember_date_joined.py b/corpus/accounts/migrations/0006_alter_executivemember_date_joined.py new file mode 100644 index 00000000..f0845c22 --- /dev/null +++ b/corpus/accounts/migrations/0006_alter_executivemember_date_joined.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.7 on 2024-06-29 07:27 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0005_alter_executivemember_date_joined_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='executivemember', + name='date_joined', + field=models.DateTimeField(default=datetime.datetime(2024, 6, 29, 7, 27, 12, 372509, tzinfo=datetime.timezone.utc), verbose_name='Date Joined'), + ), + ]