Skip to content

Commit 4974950

Browse files
Add date formatting to save_model method
Formatted the 'today' variable in the `save_model` method using Django's `date_format`. This ensures the date is displayed according to locale settings before updating the stage data.
1 parent 39e4aae commit 4974950

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

crm/site/dealadmin.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from django.http import HttpResponseRedirect
1313
from django.template.defaultfilters import truncatechars
1414
from django.utils import timezone
15+
from django.utils.formats import date_format
1516
from django.utils.safestring import mark_safe
1617
from django.utils.translation import gettext_lazy as _
1718
from django.utils.translation import gettext
@@ -397,6 +398,11 @@ def response_post_save_change(self, request, obj):
397398
def save_model(self, request, obj, form, change):
398399
now = get_now()
399400
today = get_today()
401+
formatted_today = date_format(
402+
today,
403+
format="SHORT_DATE_FORMAT",
404+
use_l10n=True
405+
)
400406
if not obj.stage:
401407
obj.stage = Stage.objects.get(
402408
default=True,
@@ -425,12 +431,12 @@ def save_model(self, request, obj, form, change):
425431
success_stage=True,
426432
department=obj.department
427433
)
428-
obj.change_stage_data(today)
434+
obj.change_stage_data(formatted_today)
429435
obj.win_closing_date = now
430436
else:
431437
obj.closing_date = None
432438
if 'stage' in form.changed_data:
433-
obj.change_stage_data(today)
439+
obj.change_stage_data(formatted_today)
434440
if obj.stage:
435441
success_stages = Stage.objects.filter(
436442
Q(success_stage=True) |

0 commit comments

Comments
 (0)