Forgive me If i'm asking a very stupid questions.
I'm trying to get name of the past months instead of numbers my django framework:
Example: For instance, if I have 12
, I want to return december or dec
Right now, I had this external python scripts that sort the day, weeks, month and years.
Here the codes for external scripts Name;basicfun: (only on the months)
#basicfun codes (external python scripts)
def selectDates(query):
if query == 'Previous-Months':
dataset = datetime.now().month - 1
dataset.strftime("%b")
return dataset
It will return to my django view to use as a filter for Queryset
Here the Frame works codes on view:
#Django view
def ph(request):
query = request.GET.get('dateRange')
fill = selectDates(query)
data = tank_system.objects.all().filter(datetime__contains=fill)
return render(request, 'FrounterWeb/extends/ph.html', {'tank': data})
Solution I had try
This link: Get month name from number
1.
dataset = datetime.now().month - 1
dataset.strftime("%b")
error:
Exception Type:AttributeError
Exception Value:'int' object has no attribute 'strftime'