SHARE
TWEET

Untitled

a guest Jun 20th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. views.py
  2.  
  3.         # gets current year and stores it in currentYear.
  4.         currentYear = datetime.now().year
  5.  
  6.         # opmToReview = posts.objects.filter(reviewYear = 'currentYear').count()  
  7.         # gives error - Cannot resolve keyword 'reviewYear' into field.
  8.  
  9.         # opmToReview = posts.objects.filter(reviewDue = 'currentYear').count()  
  10.         # gives error - 'currentYear' value has invalid format.
  11.  
  12.       #Tried this too but, doesn't work
  13.       # testing for comparing dates
  14.       def opmToReview(request):
  15.          count = 0
  16.          for post in posts
  17.              if currentYear == reviewYear
  18.              count = count + 1
  19.        return render(request, 'opmStatistics.html', {'currentYearReview' : currentYearReview})      
  20.  
  21.  
  22.  
  23. models.py
  24.  
  25.          class posts(models.Model):
  26.             OPMnumber = models.CharField(max_length = 30)
  27.             title = models.TextField()
  28.             contacts = models.CharField(max_length = 50)
  29.             dateLastReviewed = models.DateTimeField()
  30.             reviewDue = models.DateTimeField()
  31.             status = models.CharField(max_length = 20)
  32.             assignedTo = models.CharField(max_length = 30)
  33.             comments = models.TextField()
  34.  
  35.             #used to extract the year from reviewDue date
  36.             def reviewYear(self):
  37.                 return self.reviewDue.strftime('%Y')
  38.  
  39.  
  40.  
  41. '''
  42.  
  43.  
  44.  
  45. Expected results is the total number of procedure needed to be review for current year.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top