Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change timezone.now to timezone.localtime #159

Merged
merged 2 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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'),
),
]
2 changes: 1 addition & 1 deletion corpus/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default=timezone.localtime(), verbose_name="Date Joined"
default=timezone.localtime, verbose_name="Date Joined"

This shouldn't be a function call, because the function call returns the actual datetime object each time a migration is run.

)

def save(self, *args, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions corpus/virtual_expo/member_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
Loading