---------- Forwarded message --------- From: Prashanth Patelc <prashanthpat...@gmail.com> Date: Thu, Feb 23, 2023 at 5:11 PM Subject: How to create orm query if data is exist or not ? To: <django-users@googlegroups.com>
Hi all, How to create orm query with data exist or not ? How to check if approval_status Pending and Rejected with same user contains from_date approval_status User 2023-01-20 - Approved NewUser 2023-01-12 - Rejected NewUser 2023-01-06 - Approved NewUser If User contains above details in month between Create " Timesheet Model" Eg: Timesheet.objects.create(date=date,emaployee=emp,status=1) leave_data = EmployeeLeaves.objects.filter(~Q(approval_status='Approved'),~Q(approval_status='Cancelled'),~Q(approval_status='Rejected'), from_date__gte=month_first_date, to_date__lte=month_last_day, employee=request.user). If User Contains Pending Don't create Model leaves_data = EmployeeLeaves.objects.filter(~Q(approval_status='Pending'), from_date__gte=month_first_date, to_date__lte=month_last_day, employee=request.user). -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMCU6Cq7tCAKeSmmyZmcTtLH2kSRMhtqHKzz0HqDyQWyhEyK4Q%40mail.gmail.com.