Denis Merigoux лет назад: 10
Родитель
Сommit
c07fecc291
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      census/views.py

+ 2 - 2
census/views.py

83
     if request.method == 'POST':
83
     if request.method == 'POST':
84
         # create a form instance and populate it with data from the request:
84
         # create a form instance and populate it with data from the request:
85
         form = addCountForm(request.POST)
85
         form = addCountForm(request.POST)
86
-        form.fields["lesson"].queryset = Lesson.objects.filter(date__lt=datetime.now()+timedelta(7)).order_by('-date')
86
+        form.fields["lesson"].queryset = Lesson.objects.filter(date__lte=datetime.now()).order_by('-date')
87
         # check whether it's valid:
87
         # check whether it's valid:
88
         if form.is_valid():
88
         if form.is_valid():
89
             count = form.save()
89
             count = form.save()
91
     # if a GET (or any other method) we'll create a blank form
91
     # if a GET (or any other method) we'll create a blank form
92
     else:
92
     else:
93
         form = addCountForm()
93
         form = addCountForm()
94
-        form.fields["lesson"].queryset = Lesson.objects.all().order_by('-date') 
94
+        form.fields["lesson"].queryset = Lesson.objects.filter(date__lte=datetime.now()).order_by('-date') 
95
 
95
 
96
     return render(request, 'addcountTemplate.html', {'form': form})
96
     return render(request, 'addcountTemplate.html', {'form': form})