Update in django value

26 views
Skip to first unread message

Prashanth Patelc

unread,
Mar 7, 2023, 4:55:19 AM3/7/23
to django...@googlegroups.com
How to update single record particular value in django..

h_date=Holiday.objects.filter(start_date=month_start,end_date=month_end).values_list('date',flat=True)

for h_date in holiday:


Model.objects.filter(emp=request.user). update(date =h_date,in_time=None)

This above query is updating all dates I want to update particular date is available then update record..

jools

unread,
Mar 8, 2023, 4:10:59 AM3/8/23
to Django users
Hi there, from what you’re writing you need to pass an additional filter:
import datetime
Model.objects.filter(emp=request.user, date=datetime.date(2023, 3, 8)).update(date =h_date,in_time=None)
=> This will update only records for the current day.
Reply all
Reply to author
Forward
0 new messages