Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
The Date table shows all the days in the week but I don't want the sundays in the table since it is week day.
The table should show today and the past 2 days with date and day.

What I have tried:

Python
def pending(request):
     today = date.today()
     d=today.strftime("%A")
     dd = today - timedelta(days = 2) 
     dddd= today-timedelta(days = 1) 
     ddd=dd.strftime("%A")
     ddddd=dddd.strftime("%A")
     print(type(dd),"dddddd")
    k = Task.objects.filter(date__lte=today,date__gte= dd).values_list("employee")
    print("=======================================k========================",k)
    datas_list = User.objects.filter(role="Employee").exclude(id__in=k) 
    print("---------------------------datalist------------------------",datas_list)   
    page = request.GET.get('page', 1)
    paginator = Paginator(datas_list, 20)
    try:
        datas = paginator.page(page)
    except PageNotAnInteger:
        datas = paginator.page(1)
    except EmptyPage:
        datas = paginator.page(paginator.num_pages)
        
    if request.method=='POST':
        s=request.POST.get('search')
        datas_list=User.objects.filter(first_name__contains=s,role="Employee")
        page = request.GET.get('page', 1)
        paginator = Paginator(datas_list, 20)
        try:
            datas = paginator.page(page)
        except PageNotAnInteger:
            datas = paginator.page(1)
        except EmptyPage:
            datas = paginator.page(paginator.num_pages)
        return render(request,"pending_task.html",{'datas':datas,'k':k,'datas_list':datas_list,'s':s,'today':today,'dd':dd,'ddd':ddd,'d':d,'dddd':dddd,'ddddd':ddddd})
    return render(request,'pending_task.html',{'datas':datas,'k':k,'datas_list':datas_list,'today':today,'dd':dd,'ddd':ddd,'d':d,'dddd':dddd,'ddddd':ddddd,'username':username})
Posted
Updated 10-May-22 2:01am
v2

1 solution

Please, refer this: workdays 1.4 [^]

Quote:


Extend python datetime with excel-like workday addition/subtraction

functionality:

NETWORKDAYS(start_date,end_date,holidays)

Returns the number of whole working days between start_date and end_date (inclusive of both start_date and end_date). Working days exclude weekends and any dates identified in holidays. Use NETWORKDAYS to calculate employee benefits that accrue based on the number of days worked during a specific term.

WORKDAY(start_date,days,[holidays])

Returns a number that represents a date that is the indicated number of working days before or after a date (the starting date). Working days exclude weekends and any dates identified as holidays. Use WORKDAY to exclude weekends or holidays when you calculate invoice due dates, expected delivery times, or the number of days of work performed.

This module has similarities with the BusinessHours module - you may want to check it out as well to see which one better fits your needs.

 
Share this answer
 
Comments
Member 15629421 11-May-22 3:50am    
Can I know the code for my question
Maciej Los 11-May-22 3:56am    
No. It's your job. I know nothing about your project.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900