Re: use of annotate in django query

2021-07-26 Thread V. J
Hello, I'm making a list of potential customers, in about two months, we
will have a business plan ready and we will issue a digital token (ICO)
based on our product in the company.  Would you be interested in learning
more ...?

Dne so 5. čvn 2021 19:09 uživatel Lalit Suthar 
napsal:

> just replied to your mail
>
> On Sat, 5 Jun 2021 at 11:48, Eugene TUYIZERE 
> wrote:
>
>> Dear Suthar,
>>
>> Can I have your private contact?
>>
>> regards,
>>
>> On Fri, 4 Jun 2021 at 06:25, Lalit Suthar 
>> wrote:
>>
>>> my pleasure :)
>>>
>>> On Thu, 3 Jun 2021 at 20:28, Eugene TUYIZERE 
>>> wrote:
>>>
 Dear Suthar,

 Thank you very much. It works well.


 On Thu, 3 Jun 2021 at 16:48, Lalit Suthar 
 wrote:

> not sure but maybe this can work inside views replace
> chart = {
>   'chart': {'type': 'column'},
>   'title': {'text': 'Previous statistics'},
>   'xAxis': {'replist': replist},
>   'series': [arriva_days]
> }
> with
> chart = {
>   'chart': {'type': 'column'},
>   'title': {'text': 'Previous statistics'},
>   'xAxis': {'categories': replist},
>   'series': [arriva_days]
> }
>
> On Thu, 3 Jun 2021 at 18:00, Eugene TUYIZERE 
> wrote:
>
>> This what I have in summarizedchart.html:
>>
>> {% extends "layouts/base.html" %}
>> {% load static %}
>> {% block title %} Repport {% endblock %}
>>
>> 
>> {% block stylesheets %}{% endblock stylesheets %}
>>
>> {% block content %}
>>
>> 
>> 
>> 
>> 
>> 
>> Report
>>
>> 
>>
>> 
>>
>> 
>> 
>> Highcharts.chart('container', {{ chart|safe }});
>> 
>> 
>> 
>> 
>> 
>> 
>> {% endblock content %}
>> {% block custom_js %}
>>
>> {% endblock custom_js %}
>>
>> On Thu, 3 Jun 2021 at 14:22, Lalit Suthar 
>> wrote:
>>
>>> so the view is not giving error right now but maybe we are passing
>>> the data in different format then the chart is expecting.
>>> What are you using for drawing the chart? can I see the code inside
>>> "summarizedchart.html"
>>>
>>> On Thu, 3 Jun 2021 at 17:43, Eugene TUYIZERE <
>>> eugenetuyiz...@gmail.com> wrote:
>>>
 Dear Suthar,

 You saved my day. Once more, the chart is displayed but the date is
 not displayed on Xaxis. This how it is:

 [image: image.png]

 Th codes are:
 def reqChart(request):
 current_date = date.today()
 days_before = date.today()-timedelta(days=30)
 datelist = Customer_Requests.objects.values("arrival_date").
 annotate(num_req=Count("request_name")).order_by('-arrival_date')[:
 20:-1]
 replist = list()
 sumdata = list()
 for listd in datelist:
 replist.append(listd['arrival_date'])
 sumdata.append(listd['num_req'])
 arriva_days = {
 'name': 'Datess',
 'data': sumdata,
 'color': 'green'
 }
 chart = {
 'chart': {'type': 'column'},
 'title': {'text': 'Previous statistics'},
 'xAxis': {'replist': replist},
 'series': [arriva_days]
 }
 dump = json.dumps(chart,cls=DjangoJSONEncoder)
 return render(request,'summarizedchart.html',{'chart': dump})


 On Thu, 3 Jun 2021 at 13:27, lalit suthar 
 wrote:

> Hi there!
> make these couple of changes
>
> 1) from django.core.serializers.json import DjangoJSONEncoder
> 2) dump3 = json.dumps(chart3, cls=DjangoJSONEncoder)
> On Thursday, 3 June 2021 at 16:18:15 UTC+5:30 eugenet...@gmail.com
> wrote:
>
>> Dear Suthar,
>>
>> Your idea works well , but I want now to display the result on
>> chart. Below is the code I am trying to use:
>> but Am getting the error message:
>>
>> Exception Value:
>>
>> Object of type date is not JSON serializable
>>
>>
>> def reqChart(request):
>> aa = Customer_Requests.objects.values("arrival_date").annotate(
>> num_req=Count("request_name")).order_by('-arrival_date')[:20:-1]
>> print(aa)
>> datesb = list()
>> sumdata = list()
>> for dd in aa:
>> datesb.append(dd['arrival_date'])
>> sumdata.append(dd['num_req'])
>> arriva_days = {
>> 'name': 'Datess',
>> 'data': sumdata,
>> 'color': 'green'
>> }
>> chart3 = {
>> 'chart': {'type': 'column'},
>> 'title': {'text': 'Previous statistics'},
>> 'xAxis': {'datesb': datesb},
>> 'series': [arriva_days]
>> }
>> dump3 = json.dumps(chart3)
>> return render(request,'summarizedchart.html',{'chart3': dump3})
>>
>>

Re: use of annotate in django query

2021-06-05 Thread Lalit Suthar
just replied to your mail

On Sat, 5 Jun 2021 at 11:48, Eugene TUYIZERE 
wrote:

> Dear Suthar,
>
> Can I have your private contact?
>
> regards,
>
> On Fri, 4 Jun 2021 at 06:25, Lalit Suthar 
> wrote:
>
>> my pleasure :)
>>
>> On Thu, 3 Jun 2021 at 20:28, Eugene TUYIZERE 
>> wrote:
>>
>>> Dear Suthar,
>>>
>>> Thank you very much. It works well.
>>>
>>>
>>> On Thu, 3 Jun 2021 at 16:48, Lalit Suthar 
>>> wrote:
>>>
 not sure but maybe this can work inside views replace
 chart = {
   'chart': {'type': 'column'},
   'title': {'text': 'Previous statistics'},
   'xAxis': {'replist': replist},
   'series': [arriva_days]
 }
 with
 chart = {
   'chart': {'type': 'column'},
   'title': {'text': 'Previous statistics'},
   'xAxis': {'categories': replist},
   'series': [arriva_days]
 }

 On Thu, 3 Jun 2021 at 18:00, Eugene TUYIZERE 
 wrote:

> This what I have in summarizedchart.html:
>
> {% extends "layouts/base.html" %}
> {% load static %}
> {% block title %} Repport {% endblock %}
>
> 
> {% block stylesheets %}{% endblock stylesheets %}
>
> {% block content %}
>
> 
> 
> 
> 
> 
> Report
>
> 
>
> 
>
> 
> 
> Highcharts.chart('container', {{ chart|safe }});
> 
> 
> 
> 
> 
> 
> {% endblock content %}
> {% block custom_js %}
>
> {% endblock custom_js %}
>
> On Thu, 3 Jun 2021 at 14:22, Lalit Suthar 
> wrote:
>
>> so the view is not giving error right now but maybe we are passing
>> the data in different format then the chart is expecting.
>> What are you using for drawing the chart? can I see the code inside
>> "summarizedchart.html"
>>
>> On Thu, 3 Jun 2021 at 17:43, Eugene TUYIZERE <
>> eugenetuyiz...@gmail.com> wrote:
>>
>>> Dear Suthar,
>>>
>>> You saved my day. Once more, the chart is displayed but the date is
>>> not displayed on Xaxis. This how it is:
>>>
>>> [image: image.png]
>>>
>>> Th codes are:
>>> def reqChart(request):
>>> current_date = date.today()
>>> days_before = date.today()-timedelta(days=30)
>>> datelist = Customer_Requests.objects.values("arrival_date").annotate
>>> (num_req=Count("request_name")).order_by('-arrival_date')[:20:-1]
>>> replist = list()
>>> sumdata = list()
>>> for listd in datelist:
>>> replist.append(listd['arrival_date'])
>>> sumdata.append(listd['num_req'])
>>> arriva_days = {
>>> 'name': 'Datess',
>>> 'data': sumdata,
>>> 'color': 'green'
>>> }
>>> chart = {
>>> 'chart': {'type': 'column'},
>>> 'title': {'text': 'Previous statistics'},
>>> 'xAxis': {'replist': replist},
>>> 'series': [arriva_days]
>>> }
>>> dump = json.dumps(chart,cls=DjangoJSONEncoder)
>>> return render(request,'summarizedchart.html',{'chart': dump})
>>>
>>>
>>> On Thu, 3 Jun 2021 at 13:27, lalit suthar 
>>> wrote:
>>>
 Hi there!
 make these couple of changes

 1) from django.core.serializers.json import DjangoJSONEncoder
 2) dump3 = json.dumps(chart3, cls=DjangoJSONEncoder)
 On Thursday, 3 June 2021 at 16:18:15 UTC+5:30 eugenet...@gmail.com
 wrote:

> Dear Suthar,
>
> Your idea works well , but I want now to display the result on
> chart. Below is the code I am trying to use:
> but Am getting the error message:
>
> Exception Value:
>
> Object of type date is not JSON serializable
>
>
> def reqChart(request):
> aa = Customer_Requests.objects.values("arrival_date").annotate(
> num_req=Count("request_name")).order_by('-arrival_date')[:20:-1]
> print(aa)
> datesb = list()
> sumdata = list()
> for dd in aa:
> datesb.append(dd['arrival_date'])
> sumdata.append(dd['num_req'])
> arriva_days = {
> 'name': 'Datess',
> 'data': sumdata,
> 'color': 'green'
> }
> chart3 = {
> 'chart': {'type': 'column'},
> 'title': {'text': 'Previous statistics'},
> 'xAxis': {'datesb': datesb},
> 'series': [arriva_days]
> }
> dump3 = json.dumps(chart3)
> return render(request,'summarizedchart.html',{'chart3': dump3})
>
> Please once again
>
> regards,
>
>
>
> On Thu, 3 Jun 2021 at 09:00, lalit suthar 
> wrote:
>
>> this will do
>>
>> Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name")).order_by("-id")[:30:-1]
>>
>> On Thursday, 3 June 2021 at 11:37:26 UTC+5:30 abubak...@gmail.com
>> wrote:
>>
>>> to display last 3

Re: use of annotate in django query

2021-06-04 Thread Eugene TUYIZERE
Dear Suthar,

Can I have your private contact?

regards,

On Fri, 4 Jun 2021 at 06:25, Lalit Suthar  wrote:

> my pleasure :)
>
> On Thu, 3 Jun 2021 at 20:28, Eugene TUYIZERE 
> wrote:
>
>> Dear Suthar,
>>
>> Thank you very much. It works well.
>>
>>
>> On Thu, 3 Jun 2021 at 16:48, Lalit Suthar 
>> wrote:
>>
>>> not sure but maybe this can work inside views replace
>>> chart = {
>>>   'chart': {'type': 'column'},
>>>   'title': {'text': 'Previous statistics'},
>>>   'xAxis': {'replist': replist},
>>>   'series': [arriva_days]
>>> }
>>> with
>>> chart = {
>>>   'chart': {'type': 'column'},
>>>   'title': {'text': 'Previous statistics'},
>>>   'xAxis': {'categories': replist},
>>>   'series': [arriva_days]
>>> }
>>>
>>> On Thu, 3 Jun 2021 at 18:00, Eugene TUYIZERE 
>>> wrote:
>>>
 This what I have in summarizedchart.html:

 {% extends "layouts/base.html" %}
 {% load static %}
 {% block title %} Repport {% endblock %}

 
 {% block stylesheets %}{% endblock stylesheets %}

 {% block content %}

 
 
 
 
 
 Report

 

 

 
 
 Highcharts.chart('container', {{ chart|safe }});
 
 
 
 
 
 
 {% endblock content %}
 {% block custom_js %}

 {% endblock custom_js %}

 On Thu, 3 Jun 2021 at 14:22, Lalit Suthar 
 wrote:

> so the view is not giving error right now but maybe we are passing the
> data in different format then the chart is expecting.
> What are you using for drawing the chart? can I see the code inside
> "summarizedchart.html"
>
> On Thu, 3 Jun 2021 at 17:43, Eugene TUYIZERE 
> wrote:
>
>> Dear Suthar,
>>
>> You saved my day. Once more, the chart is displayed but the date is
>> not displayed on Xaxis. This how it is:
>>
>> [image: image.png]
>>
>> Th codes are:
>> def reqChart(request):
>> current_date = date.today()
>> days_before = date.today()-timedelta(days=30)
>> datelist = Customer_Requests.objects.values("arrival_date").annotate(
>> num_req=Count("request_name")).order_by('-arrival_date')[:20:-1]
>> replist = list()
>> sumdata = list()
>> for listd in datelist:
>> replist.append(listd['arrival_date'])
>> sumdata.append(listd['num_req'])
>> arriva_days = {
>> 'name': 'Datess',
>> 'data': sumdata,
>> 'color': 'green'
>> }
>> chart = {
>> 'chart': {'type': 'column'},
>> 'title': {'text': 'Previous statistics'},
>> 'xAxis': {'replist': replist},
>> 'series': [arriva_days]
>> }
>> dump = json.dumps(chart,cls=DjangoJSONEncoder)
>> return render(request,'summarizedchart.html',{'chart': dump})
>>
>>
>> On Thu, 3 Jun 2021 at 13:27, lalit suthar 
>> wrote:
>>
>>> Hi there!
>>> make these couple of changes
>>>
>>> 1) from django.core.serializers.json import DjangoJSONEncoder
>>> 2) dump3 = json.dumps(chart3, cls=DjangoJSONEncoder)
>>> On Thursday, 3 June 2021 at 16:18:15 UTC+5:30 eugenet...@gmail.com
>>> wrote:
>>>
 Dear Suthar,

 Your idea works well , but I want now to display the result on
 chart. Below is the code I am trying to use:
 but Am getting the error message:

 Exception Value:

 Object of type date is not JSON serializable


 def reqChart(request):
 aa = Customer_Requests.objects.values("arrival_date").annotate(
 num_req=Count("request_name")).order_by('-arrival_date')[:20:-1]
 print(aa)
 datesb = list()
 sumdata = list()
 for dd in aa:
 datesb.append(dd['arrival_date'])
 sumdata.append(dd['num_req'])
 arriva_days = {
 'name': 'Datess',
 'data': sumdata,
 'color': 'green'
 }
 chart3 = {
 'chart': {'type': 'column'},
 'title': {'text': 'Previous statistics'},
 'xAxis': {'datesb': datesb},
 'series': [arriva_days]
 }
 dump3 = json.dumps(chart3)
 return render(request,'summarizedchart.html',{'chart3': dump3})

 Please once again

 regards,



 On Thu, 3 Jun 2021 at 09:00, lalit suthar 
 wrote:

> this will do
>
> Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name")).order_by("-id")[:30:-1]
>
> On Thursday, 3 June 2021 at 11:37:26 UTC+5:30 abubak...@gmail.com
> wrote:
>
>> to display last 30 records you can write your code like this:
>> Customer_Requests.objects.all()[-30]
>>
>> On Thu, Jun 3, 2021 at 10:51 AM Eugene TUYIZERE <
>> eugenet...@gmail.com> wrote:
>>
>>> Dear Latit,
>>>
>>> Thank you very much. Now how ca

Re: use of annotate in django query

2021-06-03 Thread Lalit Suthar
my pleasure :)

On Thu, 3 Jun 2021 at 20:28, Eugene TUYIZERE 
wrote:

> Dear Suthar,
>
> Thank you very much. It works well.
>
>
> On Thu, 3 Jun 2021 at 16:48, Lalit Suthar 
> wrote:
>
>> not sure but maybe this can work inside views replace
>> chart = {
>>   'chart': {'type': 'column'},
>>   'title': {'text': 'Previous statistics'},
>>   'xAxis': {'replist': replist},
>>   'series': [arriva_days]
>> }
>> with
>> chart = {
>>   'chart': {'type': 'column'},
>>   'title': {'text': 'Previous statistics'},
>>   'xAxis': {'categories': replist},
>>   'series': [arriva_days]
>> }
>>
>> On Thu, 3 Jun 2021 at 18:00, Eugene TUYIZERE 
>> wrote:
>>
>>> This what I have in summarizedchart.html:
>>>
>>> {% extends "layouts/base.html" %}
>>> {% load static %}
>>> {% block title %} Repport {% endblock %}
>>>
>>> 
>>> {% block stylesheets %}{% endblock stylesheets %}
>>>
>>> {% block content %}
>>>
>>> 
>>> 
>>> 
>>> 
>>> 
>>> Report
>>>
>>> 
>>>
>>> 
>>>
>>> 
>>> 
>>> Highcharts.chart('container', {{ chart|safe }});
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> {% endblock content %}
>>> {% block custom_js %}
>>>
>>> {% endblock custom_js %}
>>>
>>> On Thu, 3 Jun 2021 at 14:22, Lalit Suthar 
>>> wrote:
>>>
 so the view is not giving error right now but maybe we are passing the
 data in different format then the chart is expecting.
 What are you using for drawing the chart? can I see the code inside
 "summarizedchart.html"

 On Thu, 3 Jun 2021 at 17:43, Eugene TUYIZERE 
 wrote:

> Dear Suthar,
>
> You saved my day. Once more, the chart is displayed but the date is
> not displayed on Xaxis. This how it is:
>
> [image: image.png]
>
> Th codes are:
> def reqChart(request):
> current_date = date.today()
> days_before = date.today()-timedelta(days=30)
> datelist = Customer_Requests.objects.values("arrival_date").annotate(
> num_req=Count("request_name")).order_by('-arrival_date')[:20:-1]
> replist = list()
> sumdata = list()
> for listd in datelist:
> replist.append(listd['arrival_date'])
> sumdata.append(listd['num_req'])
> arriva_days = {
> 'name': 'Datess',
> 'data': sumdata,
> 'color': 'green'
> }
> chart = {
> 'chart': {'type': 'column'},
> 'title': {'text': 'Previous statistics'},
> 'xAxis': {'replist': replist},
> 'series': [arriva_days]
> }
> dump = json.dumps(chart,cls=DjangoJSONEncoder)
> return render(request,'summarizedchart.html',{'chart': dump})
>
>
> On Thu, 3 Jun 2021 at 13:27, lalit suthar 
> wrote:
>
>> Hi there!
>> make these couple of changes
>>
>> 1) from django.core.serializers.json import DjangoJSONEncoder
>> 2) dump3 = json.dumps(chart3, cls=DjangoJSONEncoder)
>> On Thursday, 3 June 2021 at 16:18:15 UTC+5:30 eugenet...@gmail.com
>> wrote:
>>
>>> Dear Suthar,
>>>
>>> Your idea works well , but I want now to display the result on
>>> chart. Below is the code I am trying to use:
>>> but Am getting the error message:
>>>
>>> Exception Value:
>>>
>>> Object of type date is not JSON serializable
>>>
>>>
>>> def reqChart(request):
>>> aa = Customer_Requests.objects.values("arrival_date").annotate(
>>> num_req=Count("request_name")).order_by('-arrival_date')[:20:-1]
>>> print(aa)
>>> datesb = list()
>>> sumdata = list()
>>> for dd in aa:
>>> datesb.append(dd['arrival_date'])
>>> sumdata.append(dd['num_req'])
>>> arriva_days = {
>>> 'name': 'Datess',
>>> 'data': sumdata,
>>> 'color': 'green'
>>> }
>>> chart3 = {
>>> 'chart': {'type': 'column'},
>>> 'title': {'text': 'Previous statistics'},
>>> 'xAxis': {'datesb': datesb},
>>> 'series': [arriva_days]
>>> }
>>> dump3 = json.dumps(chart3)
>>> return render(request,'summarizedchart.html',{'chart3': dump3})
>>>
>>> Please once again
>>>
>>> regards,
>>>
>>>
>>>
>>> On Thu, 3 Jun 2021 at 09:00, lalit suthar 
>>> wrote:
>>>
 this will do

 Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name")).order_by("-id")[:30:-1]

 On Thursday, 3 June 2021 at 11:37:26 UTC+5:30 abubak...@gmail.com
 wrote:

> to display last 30 records you can write your code like this:
> Customer_Requests.objects.all()[-30]
>
> On Thu, Jun 3, 2021 at 10:51 AM Eugene TUYIZERE <
> eugenet...@gmail.com> wrote:
>
>> Dear Latit,
>>
>> Thank you very much. Now how can I display 30 last records?
>> Regardless of how many records I may have ! Just the last 30 records!
>>
>> Thank you
>>
>> On Thu, 3 Jun 2021 at 06:51, Lalit Suthar 
>> wrote:
>>
>>> > in brief, I want to transform this query in

Re: use of annotate in django query

2021-06-03 Thread Eugene TUYIZERE
Dear Suthar,

Thank you very much. It works well.


On Thu, 3 Jun 2021 at 16:48, Lalit Suthar  wrote:

> not sure but maybe this can work inside views replace
> chart = {
>   'chart': {'type': 'column'},
>   'title': {'text': 'Previous statistics'},
>   'xAxis': {'replist': replist},
>   'series': [arriva_days]
> }
> with
> chart = {
>   'chart': {'type': 'column'},
>   'title': {'text': 'Previous statistics'},
>   'xAxis': {'categories': replist},
>   'series': [arriva_days]
> }
>
> On Thu, 3 Jun 2021 at 18:00, Eugene TUYIZERE 
> wrote:
>
>> This what I have in summarizedchart.html:
>>
>> {% extends "layouts/base.html" %}
>> {% load static %}
>> {% block title %} Repport {% endblock %}
>>
>> 
>> {% block stylesheets %}{% endblock stylesheets %}
>>
>> {% block content %}
>>
>> 
>> 
>> 
>> 
>> 
>> Report
>>
>> 
>>
>> 
>>
>> 
>> 
>> Highcharts.chart('container', {{ chart|safe }});
>> 
>> 
>> 
>> 
>> 
>> 
>> {% endblock content %}
>> {% block custom_js %}
>>
>> {% endblock custom_js %}
>>
>> On Thu, 3 Jun 2021 at 14:22, Lalit Suthar 
>> wrote:
>>
>>> so the view is not giving error right now but maybe we are passing the
>>> data in different format then the chart is expecting.
>>> What are you using for drawing the chart? can I see the code inside
>>> "summarizedchart.html"
>>>
>>> On Thu, 3 Jun 2021 at 17:43, Eugene TUYIZERE 
>>> wrote:
>>>
 Dear Suthar,

 You saved my day. Once more, the chart is displayed but the date is not
 displayed on Xaxis. This how it is:

 [image: image.png]

 Th codes are:
 def reqChart(request):
 current_date = date.today()
 days_before = date.today()-timedelta(days=30)
 datelist = Customer_Requests.objects.values("arrival_date").annotate(
 num_req=Count("request_name")).order_by('-arrival_date')[:20:-1]
 replist = list()
 sumdata = list()
 for listd in datelist:
 replist.append(listd['arrival_date'])
 sumdata.append(listd['num_req'])
 arriva_days = {
 'name': 'Datess',
 'data': sumdata,
 'color': 'green'
 }
 chart = {
 'chart': {'type': 'column'},
 'title': {'text': 'Previous statistics'},
 'xAxis': {'replist': replist},
 'series': [arriva_days]
 }
 dump = json.dumps(chart,cls=DjangoJSONEncoder)
 return render(request,'summarizedchart.html',{'chart': dump})


 On Thu, 3 Jun 2021 at 13:27, lalit suthar 
 wrote:

> Hi there!
> make these couple of changes
>
> 1) from django.core.serializers.json import DjangoJSONEncoder
> 2) dump3 = json.dumps(chart3, cls=DjangoJSONEncoder)
> On Thursday, 3 June 2021 at 16:18:15 UTC+5:30 eugenet...@gmail.com
> wrote:
>
>> Dear Suthar,
>>
>> Your idea works well , but I want now to display the result on chart.
>> Below is the code I am trying to use:
>> but Am getting the error message:
>>
>> Exception Value:
>>
>> Object of type date is not JSON serializable
>>
>>
>> def reqChart(request):
>> aa = Customer_Requests.objects.values("arrival_date").annotate(
>> num_req=Count("request_name")).order_by('-arrival_date')[:20:-1]
>> print(aa)
>> datesb = list()
>> sumdata = list()
>> for dd in aa:
>> datesb.append(dd['arrival_date'])
>> sumdata.append(dd['num_req'])
>> arriva_days = {
>> 'name': 'Datess',
>> 'data': sumdata,
>> 'color': 'green'
>> }
>> chart3 = {
>> 'chart': {'type': 'column'},
>> 'title': {'text': 'Previous statistics'},
>> 'xAxis': {'datesb': datesb},
>> 'series': [arriva_days]
>> }
>> dump3 = json.dumps(chart3)
>> return render(request,'summarizedchart.html',{'chart3': dump3})
>>
>> Please once again
>>
>> regards,
>>
>>
>>
>> On Thu, 3 Jun 2021 at 09:00, lalit suthar 
>> wrote:
>>
>>> this will do
>>>
>>> Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name")).order_by("-id")[:30:-1]
>>>
>>> On Thursday, 3 June 2021 at 11:37:26 UTC+5:30 abubak...@gmail.com
>>> wrote:
>>>
 to display last 30 records you can write your code like this:
 Customer_Requests.objects.all()[-30]

 On Thu, Jun 3, 2021 at 10:51 AM Eugene TUYIZERE <
 eugenet...@gmail.com> wrote:

> Dear Latit,
>
> Thank you very much. Now how can I display 30 last records?
> Regardless of how many records I may have ! Just the last 30 records!
>
> Thank you
>
> On Thu, 3 Jun 2021 at 06:51, Lalit Suthar 
> wrote:
>
>> > in brief, I want to transform this query in django query
>> this will be equivalent to this query in django
>>
>> Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name"))
>>
>>
>> On Thu, 3 Jun 2021 at 02:02, Eugene TUYIZ

Re: use of annotate in django query

2021-06-03 Thread Lalit Suthar
not sure but maybe this can work inside views replace
chart = {
  'chart': {'type': 'column'},
  'title': {'text': 'Previous statistics'},
  'xAxis': {'replist': replist},
  'series': [arriva_days]
}
with
chart = {
  'chart': {'type': 'column'},
  'title': {'text': 'Previous statistics'},
  'xAxis': {'categories': replist},
  'series': [arriva_days]
}

On Thu, 3 Jun 2021 at 18:00, Eugene TUYIZERE 
wrote:

> This what I have in summarizedchart.html:
>
> {% extends "layouts/base.html" %}
> {% load static %}
> {% block title %} Repport {% endblock %}
>
> 
> {% block stylesheets %}{% endblock stylesheets %}
>
> {% block content %}
>
> 
> 
> 
> 
> 
> Report
>
> 
>
> 
>
> 
> 
> Highcharts.chart('container', {{ chart|safe }});
> 
> 
> 
> 
> 
> 
> {% endblock content %}
> {% block custom_js %}
>
> {% endblock custom_js %}
>
> On Thu, 3 Jun 2021 at 14:22, Lalit Suthar 
> wrote:
>
>> so the view is not giving error right now but maybe we are passing the
>> data in different format then the chart is expecting.
>> What are you using for drawing the chart? can I see the code inside
>> "summarizedchart.html"
>>
>> On Thu, 3 Jun 2021 at 17:43, Eugene TUYIZERE 
>> wrote:
>>
>>> Dear Suthar,
>>>
>>> You saved my day. Once more, the chart is displayed but the date is not
>>> displayed on Xaxis. This how it is:
>>>
>>> [image: image.png]
>>>
>>> Th codes are:
>>> def reqChart(request):
>>> current_date = date.today()
>>> days_before = date.today()-timedelta(days=30)
>>> datelist = Customer_Requests.objects.values("arrival_date").annotate(
>>> num_req=Count("request_name")).order_by('-arrival_date')[:20:-1]
>>> replist = list()
>>> sumdata = list()
>>> for listd in datelist:
>>> replist.append(listd['arrival_date'])
>>> sumdata.append(listd['num_req'])
>>> arriva_days = {
>>> 'name': 'Datess',
>>> 'data': sumdata,
>>> 'color': 'green'
>>> }
>>> chart = {
>>> 'chart': {'type': 'column'},
>>> 'title': {'text': 'Previous statistics'},
>>> 'xAxis': {'replist': replist},
>>> 'series': [arriva_days]
>>> }
>>> dump = json.dumps(chart,cls=DjangoJSONEncoder)
>>> return render(request,'summarizedchart.html',{'chart': dump})
>>>
>>>
>>> On Thu, 3 Jun 2021 at 13:27, lalit suthar 
>>> wrote:
>>>
 Hi there!
 make these couple of changes

 1) from django.core.serializers.json import DjangoJSONEncoder
 2) dump3 = json.dumps(chart3, cls=DjangoJSONEncoder)
 On Thursday, 3 June 2021 at 16:18:15 UTC+5:30 eugenet...@gmail.com
 wrote:

> Dear Suthar,
>
> Your idea works well , but I want now to display the result on chart.
> Below is the code I am trying to use:
> but Am getting the error message:
>
> Exception Value:
>
> Object of type date is not JSON serializable
>
>
> def reqChart(request):
> aa = Customer_Requests.objects.values("arrival_date").annotate(num_req
> =Count("request_name")).order_by('-arrival_date')[:20:-1]
> print(aa)
> datesb = list()
> sumdata = list()
> for dd in aa:
> datesb.append(dd['arrival_date'])
> sumdata.append(dd['num_req'])
> arriva_days = {
> 'name': 'Datess',
> 'data': sumdata,
> 'color': 'green'
> }
> chart3 = {
> 'chart': {'type': 'column'},
> 'title': {'text': 'Previous statistics'},
> 'xAxis': {'datesb': datesb},
> 'series': [arriva_days]
> }
> dump3 = json.dumps(chart3)
> return render(request,'summarizedchart.html',{'chart3': dump3})
>
> Please once again
>
> regards,
>
>
>
> On Thu, 3 Jun 2021 at 09:00, lalit suthar 
> wrote:
>
>> this will do
>>
>> Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name")).order_by("-id")[:30:-1]
>>
>> On Thursday, 3 June 2021 at 11:37:26 UTC+5:30 abubak...@gmail.com
>> wrote:
>>
>>> to display last 30 records you can write your code like this:
>>> Customer_Requests.objects.all()[-30]
>>>
>>> On Thu, Jun 3, 2021 at 10:51 AM Eugene TUYIZERE <
>>> eugenet...@gmail.com> wrote:
>>>
 Dear Latit,

 Thank you very much. Now how can I display 30 last records?
 Regardless of how many records I may have ! Just the last 30 records!

 Thank you

 On Thu, 3 Jun 2021 at 06:51, Lalit Suthar 
 wrote:

> > in brief, I want to transform this query in django query
> this will be equivalent to this query in django
>
> Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name"))
>
>
> On Thu, 3 Jun 2021 at 02:02, Eugene TUYIZERE 
> wrote:
>
>> in brief, I want to transform this query in django query
>>
>> [image: image.png]
>>
>> On Wed, 2 Jun 2021 at 21:56, Eugene TUYIZERE <
>> eugenet...@gmail.com> wrote:
>>
>>> Dear Sebatian,
>>>
>

Re: use of annotate in django query

2021-06-03 Thread Eugene TUYIZERE
This what I have in summarizedchart.html:

{% extends "layouts/base.html" %}
{% load static %}
{% block title %} Repport {% endblock %}


{% block stylesheets %}{% endblock stylesheets %}

{% block content %}






Report







Highcharts.chart('container', {{ chart|safe }});






{% endblock content %}
{% block custom_js %}

{% endblock custom_js %}

On Thu, 3 Jun 2021 at 14:22, Lalit Suthar  wrote:

> so the view is not giving error right now but maybe we are passing the
> data in different format then the chart is expecting.
> What are you using for drawing the chart? can I see the code inside
> "summarizedchart.html"
>
> On Thu, 3 Jun 2021 at 17:43, Eugene TUYIZERE 
> wrote:
>
>> Dear Suthar,
>>
>> You saved my day. Once more, the chart is displayed but the date is not
>> displayed on Xaxis. This how it is:
>>
>> [image: image.png]
>>
>> Th codes are:
>> def reqChart(request):
>> current_date = date.today()
>> days_before = date.today()-timedelta(days=30)
>> datelist = Customer_Requests.objects.values("arrival_date").annotate(
>> num_req=Count("request_name")).order_by('-arrival_date')[:20:-1]
>> replist = list()
>> sumdata = list()
>> for listd in datelist:
>> replist.append(listd['arrival_date'])
>> sumdata.append(listd['num_req'])
>> arriva_days = {
>> 'name': 'Datess',
>> 'data': sumdata,
>> 'color': 'green'
>> }
>> chart = {
>> 'chart': {'type': 'column'},
>> 'title': {'text': 'Previous statistics'},
>> 'xAxis': {'replist': replist},
>> 'series': [arriva_days]
>> }
>> dump = json.dumps(chart,cls=DjangoJSONEncoder)
>> return render(request,'summarizedchart.html',{'chart': dump})
>>
>>
>> On Thu, 3 Jun 2021 at 13:27, lalit suthar 
>> wrote:
>>
>>> Hi there!
>>> make these couple of changes
>>>
>>> 1) from django.core.serializers.json import DjangoJSONEncoder
>>> 2) dump3 = json.dumps(chart3, cls=DjangoJSONEncoder)
>>> On Thursday, 3 June 2021 at 16:18:15 UTC+5:30 eugenet...@gmail.com
>>> wrote:
>>>
 Dear Suthar,

 Your idea works well , but I want now to display the result on chart.
 Below is the code I am trying to use:
 but Am getting the error message:

 Exception Value:

 Object of type date is not JSON serializable


 def reqChart(request):
 aa = Customer_Requests.objects.values("arrival_date").annotate(num_req=
 Count("request_name")).order_by('-arrival_date')[:20:-1]
 print(aa)
 datesb = list()
 sumdata = list()
 for dd in aa:
 datesb.append(dd['arrival_date'])
 sumdata.append(dd['num_req'])
 arriva_days = {
 'name': 'Datess',
 'data': sumdata,
 'color': 'green'
 }
 chart3 = {
 'chart': {'type': 'column'},
 'title': {'text': 'Previous statistics'},
 'xAxis': {'datesb': datesb},
 'series': [arriva_days]
 }
 dump3 = json.dumps(chart3)
 return render(request,'summarizedchart.html',{'chart3': dump3})

 Please once again

 regards,



 On Thu, 3 Jun 2021 at 09:00, lalit suthar  wrote:

> this will do
>
> Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name")).order_by("-id")[:30:-1]
>
> On Thursday, 3 June 2021 at 11:37:26 UTC+5:30 abubak...@gmail.com
> wrote:
>
>> to display last 30 records you can write your code like this:
>> Customer_Requests.objects.all()[-30]
>>
>> On Thu, Jun 3, 2021 at 10:51 AM Eugene TUYIZERE 
>> wrote:
>>
>>> Dear Latit,
>>>
>>> Thank you very much. Now how can I display 30 last records?
>>> Regardless of how many records I may have ! Just the last 30 records!
>>>
>>> Thank you
>>>
>>> On Thu, 3 Jun 2021 at 06:51, Lalit Suthar 
>>> wrote:
>>>
 > in brief, I want to transform this query in django query
 this will be equivalent to this query in django

 Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name"))


 On Thu, 3 Jun 2021 at 02:02, Eugene TUYIZERE 
 wrote:

> in brief, I want to transform this query in django query
>
> [image: image.png]
>
> On Wed, 2 Jun 2021 at 21:56, Eugene TUYIZERE 
> wrote:
>
>> Dear Sebatian,
>>
>> This is what I get:
>>
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE 
>> `crms_customer_requests`.`arrival_date` >=
>> 2021-05-03 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY 
>> NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE 
>> `crms_customer_requests`.`arrival_date` >=
>> 2021-05-04 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY 
>> NULL
>

Re: use of annotate in django query

2021-06-03 Thread Lalit Suthar
so the view is not giving error right now but maybe we are passing the data
in different format then the chart is expecting.
What are you using for drawing the chart? can I see the code inside
"summarizedchart.html"

On Thu, 3 Jun 2021 at 17:43, Eugene TUYIZERE 
wrote:

> Dear Suthar,
>
> You saved my day. Once more, the chart is displayed but the date is not
> displayed on Xaxis. This how it is:
>
> [image: image.png]
>
> Th codes are:
> def reqChart(request):
> current_date = date.today()
> days_before = date.today()-timedelta(days=30)
> datelist = Customer_Requests.objects.values("arrival_date").annotate(
> num_req=Count("request_name")).order_by('-arrival_date')[:20:-1]
> replist = list()
> sumdata = list()
> for listd in datelist:
> replist.append(listd['arrival_date'])
> sumdata.append(listd['num_req'])
> arriva_days = {
> 'name': 'Datess',
> 'data': sumdata,
> 'color': 'green'
> }
> chart = {
> 'chart': {'type': 'column'},
> 'title': {'text': 'Previous statistics'},
> 'xAxis': {'replist': replist},
> 'series': [arriva_days]
> }
> dump = json.dumps(chart,cls=DjangoJSONEncoder)
> return render(request,'summarizedchart.html',{'chart': dump})
>
>
> On Thu, 3 Jun 2021 at 13:27, lalit suthar 
> wrote:
>
>> Hi there!
>> make these couple of changes
>>
>> 1) from django.core.serializers.json import DjangoJSONEncoder
>> 2) dump3 = json.dumps(chart3, cls=DjangoJSONEncoder)
>> On Thursday, 3 June 2021 at 16:18:15 UTC+5:30 eugenet...@gmail.com wrote:
>>
>>> Dear Suthar,
>>>
>>> Your idea works well , but I want now to display the result on chart.
>>> Below is the code I am trying to use:
>>> but Am getting the error message:
>>>
>>> Exception Value:
>>>
>>> Object of type date is not JSON serializable
>>>
>>>
>>> def reqChart(request):
>>> aa = Customer_Requests.objects.values("arrival_date").annotate(num_req=
>>> Count("request_name")).order_by('-arrival_date')[:20:-1]
>>> print(aa)
>>> datesb = list()
>>> sumdata = list()
>>> for dd in aa:
>>> datesb.append(dd['arrival_date'])
>>> sumdata.append(dd['num_req'])
>>> arriva_days = {
>>> 'name': 'Datess',
>>> 'data': sumdata,
>>> 'color': 'green'
>>> }
>>> chart3 = {
>>> 'chart': {'type': 'column'},
>>> 'title': {'text': 'Previous statistics'},
>>> 'xAxis': {'datesb': datesb},
>>> 'series': [arriva_days]
>>> }
>>> dump3 = json.dumps(chart3)
>>> return render(request,'summarizedchart.html',{'chart3': dump3})
>>>
>>> Please once again
>>>
>>> regards,
>>>
>>>
>>>
>>> On Thu, 3 Jun 2021 at 09:00, lalit suthar  wrote:
>>>
 this will do

 Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name")).order_by("-id")[:30:-1]

 On Thursday, 3 June 2021 at 11:37:26 UTC+5:30 abubak...@gmail.com
 wrote:

> to display last 30 records you can write your code like this:
> Customer_Requests.objects.all()[-30]
>
> On Thu, Jun 3, 2021 at 10:51 AM Eugene TUYIZERE 
> wrote:
>
>> Dear Latit,
>>
>> Thank you very much. Now how can I display 30 last records?
>> Regardless of how many records I may have ! Just the last 30 records!
>>
>> Thank you
>>
>> On Thu, 3 Jun 2021 at 06:51, Lalit Suthar 
>> wrote:
>>
>>> > in brief, I want to transform this query in django query
>>> this will be equivalent to this query in django
>>>
>>> Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name"))
>>>
>>>
>>> On Thu, 3 Jun 2021 at 02:02, Eugene TUYIZERE 
>>> wrote:
>>>
 in brief, I want to transform this query in django query

 [image: image.png]

 On Wed, 2 Jun 2021 at 21:56, Eugene TUYIZERE 
 wrote:

> Dear Sebatian,
>
> This is what I get:
>
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE 
> `crms_customer_requests`.`arrival_date` >=
> 2021-05-03 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY 
> NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE 
> `crms_customer_requests`.`arrival_date` >=
> 2021-05-04 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY 
> NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE 
> `crms_customer_requests`.`arrival_date` >=
> 2021-05-05 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY 
> NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE 
> `crms_customer_requests`.`arrival_date` >=
> 2021-05-0

Re: use of annotate in django query

2021-06-03 Thread Eugene TUYIZERE
Dear Suthar,

You saved my day. Once more, the chart is displayed but the date is not
displayed on Xaxis. This how it is:

[image: image.png]

Th codes are:
def reqChart(request):
current_date = date.today()
days_before = date.today()-timedelta(days=30)
datelist = Customer_Requests.objects.values("arrival_date").annotate(num_req
=Count("request_name")).order_by('-arrival_date')[:20:-1]
replist = list()
sumdata = list()
for listd in datelist:
replist.append(listd['arrival_date'])
sumdata.append(listd['num_req'])
arriva_days = {
'name': 'Datess',
'data': sumdata,
'color': 'green'
}
chart = {
'chart': {'type': 'column'},
'title': {'text': 'Previous statistics'},
'xAxis': {'replist': replist},
'series': [arriva_days]
}
dump = json.dumps(chart,cls=DjangoJSONEncoder)
return render(request,'summarizedchart.html',{'chart': dump})


On Thu, 3 Jun 2021 at 13:27, lalit suthar  wrote:

> Hi there!
> make these couple of changes
>
> 1) from django.core.serializers.json import DjangoJSONEncoder
> 2) dump3 = json.dumps(chart3, cls=DjangoJSONEncoder)
> On Thursday, 3 June 2021 at 16:18:15 UTC+5:30 eugenet...@gmail.com wrote:
>
>> Dear Suthar,
>>
>> Your idea works well , but I want now to display the result on chart.
>> Below is the code I am trying to use:
>> but Am getting the error message:
>>
>> Exception Value:
>>
>> Object of type date is not JSON serializable
>>
>>
>> def reqChart(request):
>> aa = Customer_Requests.objects.values("arrival_date").annotate(num_req=
>> Count("request_name")).order_by('-arrival_date')[:20:-1]
>> print(aa)
>> datesb = list()
>> sumdata = list()
>> for dd in aa:
>> datesb.append(dd['arrival_date'])
>> sumdata.append(dd['num_req'])
>> arriva_days = {
>> 'name': 'Datess',
>> 'data': sumdata,
>> 'color': 'green'
>> }
>> chart3 = {
>> 'chart': {'type': 'column'},
>> 'title': {'text': 'Previous statistics'},
>> 'xAxis': {'datesb': datesb},
>> 'series': [arriva_days]
>> }
>> dump3 = json.dumps(chart3)
>> return render(request,'summarizedchart.html',{'chart3': dump3})
>>
>> Please once again
>>
>> regards,
>>
>>
>>
>> On Thu, 3 Jun 2021 at 09:00, lalit suthar  wrote:
>>
>>> this will do
>>>
>>> Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name")).order_by("-id")[:30:-1]
>>>
>>> On Thursday, 3 June 2021 at 11:37:26 UTC+5:30 abubak...@gmail.com wrote:
>>>
 to display last 30 records you can write your code like this:
 Customer_Requests.objects.all()[-30]

 On Thu, Jun 3, 2021 at 10:51 AM Eugene TUYIZERE 
 wrote:

> Dear Latit,
>
> Thank you very much. Now how can I display 30 last records? Regardless
> of how many records I may have ! Just the last 30 records!
>
> Thank you
>
> On Thu, 3 Jun 2021 at 06:51, Lalit Suthar 
> wrote:
>
>> > in brief, I want to transform this query in django query
>> this will be equivalent to this query in django
>>
>> Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name"))
>>
>>
>> On Thu, 3 Jun 2021 at 02:02, Eugene TUYIZERE 
>> wrote:
>>
>>> in brief, I want to transform this query in django query
>>>
>>> [image: image.png]
>>>
>>> On Wed, 2 Jun 2021 at 21:56, Eugene TUYIZERE 
>>> wrote:
>>>
 Dear Sebatian,

 This is what I get:

 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` 
 >=
 2021-05-03 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY 
 NULL
 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` 
 >=
 2021-05-04 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY 
 NULL
 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` 
 >=
 2021-05-05 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY 
 NULL
 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` 
 >=
 2021-05-06 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY 
 NULL
 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` 
 >=
 2021-05-07 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY 
 NULL
 SELECT `crms_customer_requests`.`arrival_date`,
 

Re: use of annotate in django query

2021-06-03 Thread lalit suthar
Hi there! 
make these couple of changes 

1) from django.core.serializers.json import DjangoJSONEncoder 
2) dump3 = json.dumps(chart3, cls=DjangoJSONEncoder)
On Thursday, 3 June 2021 at 16:18:15 UTC+5:30 eugenet...@gmail.com wrote:

> Dear Suthar,
>
> Your idea works well , but I want now to display the result on chart. 
> Below is the code I am trying to use:
> but Am getting the error message:
>
> Exception Value: 
>
> Object of type date is not JSON serializable
>
>
> def reqChart(request): 
> aa = Customer_Requests.objects.values("arrival_date").annotate(num_req=
> Count("request_name")).order_by('-arrival_date')[:20:-1]
> print(aa)
> datesb = list()
> sumdata = list()
> for dd in aa:
> datesb.append(dd['arrival_date'])
> sumdata.append(dd['num_req'])
> arriva_days = {
> 'name': 'Datess',
> 'data': sumdata,
> 'color': 'green'
> }
> chart3 = {
> 'chart': {'type': 'column'},
> 'title': {'text': 'Previous statistics'},
> 'xAxis': {'datesb': datesb},
> 'series': [arriva_days]
> }
> dump3 = json.dumps(chart3)
> return render(request,'summarizedchart.html',{'chart3': dump3})
>
> Please once again
>
> regards, 
>
>
>
> On Thu, 3 Jun 2021 at 09:00, lalit suthar  wrote:
>
>> this will do 
>>
>> Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name")).order_by("-id")[:30:-1]
>>
>> On Thursday, 3 June 2021 at 11:37:26 UTC+5:30 abubak...@gmail.com wrote:
>>
>>> to display last 30 records you can write your code like this: 
>>> Customer_Requests.objects.all()[-30]
>>>
>>> On Thu, Jun 3, 2021 at 10:51 AM Eugene TUYIZERE  
>>> wrote:
>>>
 Dear Latit,

 Thank you very much. Now how can I display 30 last records? Regardless 
 of how many records I may have ! Just the last 30 records!

 Thank you

 On Thu, 3 Jun 2021 at 06:51, Lalit Suthar  wrote:

> > in brief, I want to transform this query in django query
> this will be equivalent to this query in django 
>
> Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name"))
>
>
> On Thu, 3 Jun 2021 at 02:02, Eugene TUYIZERE  
> wrote:
>
>> in brief, I want to transform this query in django query
>>
>> [image: image.png]
>>
>> On Wed, 2 Jun 2021 at 21:56, Eugene TUYIZERE  
>> wrote:
>>
>>> Dear Sebatian,
>>>
>>> This is what I get:
>>>
>>> SELECT `crms_customer_requests`.`arrival_date`, 
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` 
>>> >= 
>>> 2021-05-03 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY 
>>> NULL
>>> SELECT `crms_customer_requests`.`arrival_date`, 
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` 
>>> >= 
>>> 2021-05-04 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY 
>>> NULL
>>> SELECT `crms_customer_requests`.`arrival_date`, 
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` 
>>> >= 
>>> 2021-05-05 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY 
>>> NULL
>>> SELECT `crms_customer_requests`.`arrival_date`, 
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` 
>>> >= 
>>> 2021-05-06 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY 
>>> NULL
>>> SELECT `crms_customer_requests`.`arrival_date`, 
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` 
>>> >= 
>>> 2021-05-07 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY 
>>> NULL
>>> SELECT `crms_customer_requests`.`arrival_date`, 
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` 
>>> >= 
>>> 2021-05-08 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY 
>>> NULL
>>> SELECT `crms_customer_requests`.`arrival_date`, 
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` 
>>> >= 
>>> 2021-05-09 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY 
>>> NULL
>>> SELECT `crms_customer_requests`.`arrival_date`, 
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` 
>>> >= 
>>> 2021-05-10 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY 
>>> NULL
>>> SELECT `crms_customer_requests`.`arrival_date`, 
>>> COUNT(`crms_customer_requests`.`request_name`) AS `cou

Re: use of annotate in django query

2021-06-03 Thread Eugene TUYIZERE
Dear Suthar,

Your idea works well , but I want now to display the result on chart. Below
is the code I am trying to use:
but Am getting the error message:

Exception Value:

Object of type date is not JSON serializable


def reqChart(request):
aa = Customer_Requests.objects.values("arrival_date").annotate(num_req=Count
("request_name")).order_by('-arrival_date')[:20:-1]
print(aa)
datesb = list()
sumdata = list()
for dd in aa:
datesb.append(dd['arrival_date'])
sumdata.append(dd['num_req'])
arriva_days = {
'name': 'Datess',
'data': sumdata,
'color': 'green'
}
chart3 = {
'chart': {'type': 'column'},
'title': {'text': 'Previous statistics'},
'xAxis': {'datesb': datesb},
'series': [arriva_days]
}
dump3 = json.dumps(chart3)
return render(request,'summarizedchart.html',{'chart3': dump3})

Please once again

regards,



On Thu, 3 Jun 2021 at 09:00, lalit suthar  wrote:

> this will do
>
> Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name")).order_by("-id")[:30:-1]
>
> On Thursday, 3 June 2021 at 11:37:26 UTC+5:30 abubak...@gmail.com wrote:
>
>> to display last 30 records you can write your code like this:
>> Customer_Requests.objects.all()[-30]
>>
>> On Thu, Jun 3, 2021 at 10:51 AM Eugene TUYIZERE 
>> wrote:
>>
>>> Dear Latit,
>>>
>>> Thank you very much. Now how can I display 30 last records? Regardless
>>> of how many records I may have ! Just the last 30 records!
>>>
>>> Thank you
>>>
>>> On Thu, 3 Jun 2021 at 06:51, Lalit Suthar  wrote:
>>>
 > in brief, I want to transform this query in django query
 this will be equivalent to this query in django

 Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name"))


 On Thu, 3 Jun 2021 at 02:02, Eugene TUYIZERE 
 wrote:

> in brief, I want to transform this query in django query
>
> [image: image.png]
>
> On Wed, 2 Jun 2021 at 21:56, Eugene TUYIZERE 
> wrote:
>
>> Dear Sebatian,
>>
>> This is what I get:
>>
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-03 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-04 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-05 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-06 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-07 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-08 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-09 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-10 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-11 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-12 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_n

Re: use of annotate in django query

2021-06-02 Thread lalit suthar
this will do 
Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name")).order_by("-id")[:30:-1]

On Thursday, 3 June 2021 at 11:37:26 UTC+5:30 abubak...@gmail.com wrote:

> to display last 30 records you can write your code like this: 
> Customer_Requests.objects.all()[-30]
>
> On Thu, Jun 3, 2021 at 10:51 AM Eugene TUYIZERE  
> wrote:
>
>> Dear Latit,
>>
>> Thank you very much. Now how can I display 30 last records? Regardless of 
>> how many records I may have ! Just the last 30 records!
>>
>> Thank you
>>
>> On Thu, 3 Jun 2021 at 06:51, Lalit Suthar  wrote:
>>
>>> > in brief, I want to transform this query in django query
>>> this will be equivalent to this query in django 
>>>
>>> Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name"))
>>>
>>>
>>> On Thu, 3 Jun 2021 at 02:02, Eugene TUYIZERE  
>>> wrote:
>>>
 in brief, I want to transform this query in django query

 [image: image.png]

 On Wed, 2 Jun 2021 at 21:56, Eugene TUYIZERE  
 wrote:

> Dear Sebatian,
>
> This is what I get:
>
> SELECT `crms_customer_requests`.`arrival_date`, 
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >= 
> 2021-05-03 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`, 
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >= 
> 2021-05-04 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`, 
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >= 
> 2021-05-05 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`, 
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >= 
> 2021-05-06 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`, 
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >= 
> 2021-05-07 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`, 
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >= 
> 2021-05-08 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`, 
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >= 
> 2021-05-09 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`, 
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >= 
> 2021-05-10 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`, 
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >= 
> 2021-05-11 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`, 
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >= 
> 2021-05-12 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`, 
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >= 
> 2021-05-13 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`, 
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >= 
> 2021-05-14 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`, 
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >= 
> 2021-05-15 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`, 
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM 
> `crms_customer_requests` WHERE `crms_c

Re: use of annotate in django query

2021-06-02 Thread DJANGO DEVELOPER
to display last 30 records you can write your code like this:
Customer_Requests.objects.all()[-30]

On Thu, Jun 3, 2021 at 10:51 AM Eugene TUYIZERE 
wrote:

> Dear Latit,
>
> Thank you very much. Now how can I display 30 last records? Regardless of
> how many records I may have ! Just the last 30 records!
>
> Thank you
>
> On Thu, 3 Jun 2021 at 06:51, Lalit Suthar 
> wrote:
>
>> > in brief, I want to transform this query in django query
>> this will be equivalent to this query in django
>>
>> Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name"))
>>
>>
>> On Thu, 3 Jun 2021 at 02:02, Eugene TUYIZERE 
>> wrote:
>>
>>> in brief, I want to transform this query in django query
>>>
>>> [image: image.png]
>>>
>>> On Wed, 2 Jun 2021 at 21:56, Eugene TUYIZERE 
>>> wrote:
>>>
 Dear Sebatian,

 This is what I get:

 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
 2021-05-03 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
 2021-05-04 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
 2021-05-05 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
 2021-05-06 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
 2021-05-07 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
 2021-05-08 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
 2021-05-09 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
 2021-05-10 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
 2021-05-11 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
 2021-05-12 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
 2021-05-13 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
 2021-05-14 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
 2021-05-15 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
 2021-05-16 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
 SELECT `crms_customer_requests`.`arrival_date`,
 COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
 `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
 2021-05-17 GROUP BY `

Re: use of annotate in django query

2021-06-02 Thread Eugene TUYIZERE
Dear Latit,

Thank you very much. Now how can I display 30 last records? Regardless of
how many records I may have ! Just the last 30 records!

Thank you

On Thu, 3 Jun 2021 at 06:51, Lalit Suthar  wrote:

> > in brief, I want to transform this query in django query
> this will be equivalent to this query in django
>
> Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name"))
>
>
> On Thu, 3 Jun 2021 at 02:02, Eugene TUYIZERE 
> wrote:
>
>> in brief, I want to transform this query in django query
>>
>> [image: image.png]
>>
>> On Wed, 2 Jun 2021 at 21:56, Eugene TUYIZERE 
>> wrote:
>>
>>> Dear Sebatian,
>>>
>>> This is what I get:
>>>
>>> SELECT `crms_customer_requests`.`arrival_date`,
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>>> 2021-05-03 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>>> SELECT `crms_customer_requests`.`arrival_date`,
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>>> 2021-05-04 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>>> SELECT `crms_customer_requests`.`arrival_date`,
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>>> 2021-05-05 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>>> SELECT `crms_customer_requests`.`arrival_date`,
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>>> 2021-05-06 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>>> SELECT `crms_customer_requests`.`arrival_date`,
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>>> 2021-05-07 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>>> SELECT `crms_customer_requests`.`arrival_date`,
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>>> 2021-05-08 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>>> SELECT `crms_customer_requests`.`arrival_date`,
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>>> 2021-05-09 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>>> SELECT `crms_customer_requests`.`arrival_date`,
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>>> 2021-05-10 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>>> SELECT `crms_customer_requests`.`arrival_date`,
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>>> 2021-05-11 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>>> SELECT `crms_customer_requests`.`arrival_date`,
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>>> 2021-05-12 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>>> SELECT `crms_customer_requests`.`arrival_date`,
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>>> 2021-05-13 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>>> SELECT `crms_customer_requests`.`arrival_date`,
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>>> 2021-05-14 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>>> SELECT `crms_customer_requests`.`arrival_date`,
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>>> 2021-05-15 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>>> SELECT `crms_customer_requests`.`arrival_date`,
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>>> 2021-05-16 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>>> SELECT `crms_customer_requests`.`arrival_date`,
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>>> 2021-05-17 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>>> SELECT `crms_customer_requests`.`arrival_date`,
>>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>>>

Re: use of annotate in django query

2021-06-02 Thread Lalit Suthar
> in brief, I want to transform this query in django query
this will be equivalent to this query in django
Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name"))


On Thu, 3 Jun 2021 at 02:02, Eugene TUYIZERE 
wrote:

> in brief, I want to transform this query in django query
>
> [image: image.png]
>
> On Wed, 2 Jun 2021 at 21:56, Eugene TUYIZERE 
> wrote:
>
>> Dear Sebatian,
>>
>> This is what I get:
>>
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-03 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-04 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-05 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-06 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-07 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-08 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-09 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-10 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-11 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-12 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-13 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-14 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-15 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-16 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-17 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-18 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
>> SELECT `crms_customer_requests`.`arrival_date`,
>> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
>> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
>> 2021-05-19 GROUP BY `crm

Re: use of annotate in django query

2021-06-02 Thread Eugene TUYIZERE
in brief, I want to transform this query in django query

[image: image.png]

On Wed, 2 Jun 2021 at 21:56, Eugene TUYIZERE 
wrote:

> Dear Sebatian,
>
> This is what I get:
>
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
> 2021-05-03 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
> 2021-05-04 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
> 2021-05-05 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
> 2021-05-06 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
> 2021-05-07 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
> 2021-05-08 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
> 2021-05-09 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
> 2021-05-10 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
> 2021-05-11 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
> 2021-05-12 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
> 2021-05-13 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
> 2021-05-14 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
> 2021-05-15 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
> 2021-05-16 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
> 2021-05-17 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
> 2021-05-18 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
> 2021-05-19 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_customer_requests`.`arrival_date`,
> COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
> `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
> 2021-05-20 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
> SELECT `crms_cus

Re: use of annotate in django query

2021-06-02 Thread Eugene TUYIZERE
Dear Sebatian,

This is what I get:

SELECT `crms_customer_requests`.`arrival_date`,
COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
`crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
2021-05-03 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
SELECT `crms_customer_requests`.`arrival_date`,
COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
`crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
2021-05-04 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
SELECT `crms_customer_requests`.`arrival_date`,
COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
`crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
2021-05-05 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
SELECT `crms_customer_requests`.`arrival_date`,
COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
`crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
2021-05-06 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
SELECT `crms_customer_requests`.`arrival_date`,
COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
`crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
2021-05-07 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
SELECT `crms_customer_requests`.`arrival_date`,
COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
`crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
2021-05-08 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
SELECT `crms_customer_requests`.`arrival_date`,
COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
`crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
2021-05-09 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
SELECT `crms_customer_requests`.`arrival_date`,
COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
`crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
2021-05-10 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
SELECT `crms_customer_requests`.`arrival_date`,
COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
`crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
2021-05-11 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
SELECT `crms_customer_requests`.`arrival_date`,
COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
`crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
2021-05-12 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
SELECT `crms_customer_requests`.`arrival_date`,
COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
`crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
2021-05-13 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
SELECT `crms_customer_requests`.`arrival_date`,
COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
`crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
2021-05-14 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
SELECT `crms_customer_requests`.`arrival_date`,
COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
`crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
2021-05-15 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
SELECT `crms_customer_requests`.`arrival_date`,
COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
`crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
2021-05-16 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
SELECT `crms_customer_requests`.`arrival_date`,
COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
`crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
2021-05-17 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
SELECT `crms_customer_requests`.`arrival_date`,
COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
`crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
2021-05-18 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
SELECT `crms_customer_requests`.`arrival_date`,
COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
`crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
2021-05-19 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
SELECT `crms_customer_requests`.`arrival_date`,
COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
`crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
2021-05-20 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
SELECT `crms_customer_requests`.`arrival_date`,
COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM
`crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >=
2021-05-21 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL
SELECT `crms_customer_requests`.`arrival_

Re: use of annotate in django query

2021-06-02 Thread Sebastian Jung
Hi Eugene,

Please make Print(report.query) then you get SQL querys and Most of time i
get an Idea what's wrong

Regards

Eugene TUYIZERE  schrieb am Mi., 2. Juni 2021,
21:41:

> Dear Team,
>
> I need help. I am working on a project where one of the tables is about
> requests. I want to have a report of the number of requests on each day in
> the last 30 days, something like this:
> [image: image.png]I I used the code below just before displaying on the
> chart but the code gives me wrong information
>
> def reqChart(request):
> current_date = date.today()
> days_before = date.today()-timedelta(days=30)
> for dt in daterange(days_before,current_date):
> reports = Customer_Requests.objects.filter(arrival_date__gte=dt).\
> extra({'day':"date(arrival_date)"}).\
> values('arrival_date').annotate(count=Count('request_name'))
> print(reports)
>
>
> And I need help
> --
> *TUYIZERE Eugene*
>
>
>
> *Msc Degree in Mathematical Science*
>
> *African Institute for Mathematical Sciences (AIMS Cameroon)Crystal
> Garden-Lime, Cameroon*
>
> Bsc in Computer Science
>
> *UR-Nyagatare Campus*
>
> Email: eugene.tuyiz...@aims-cameroon.org
>eugenetuyiz...@gmail.com
>
> Tel: (+250) 7 88 26 33 38, (+250) 7 22 26 33 38
>
> --
> 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/CABxpZHstWyfMVKQhJb%3DxGKff3p3V%2BFQ_w3DkYVpOe-pEW2ySKg%40mail.gmail.com
> 
> .
>

-- 
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/CAKGT9myp4HU6%2BZo6d-JqeaTPsevFBMi_DzU_xuwo3LUja%3DxzRw%40mail.gmail.com.


use of annotate in django query

2021-06-02 Thread Eugene TUYIZERE
Dear Team,

I need help. I am working on a project where one of the tables is about
requests. I want to have a report of the number of requests on each day in
the last 30 days, something like this:
[image: image.png]I I used the code below just before displaying on the
chart but the code gives me wrong information

def reqChart(request):
current_date = date.today()
days_before = date.today()-timedelta(days=30)
for dt in daterange(days_before,current_date):
reports = Customer_Requests.objects.filter(arrival_date__gte=dt).\
extra({'day':"date(arrival_date)"}).\
values('arrival_date').annotate(count=Count('request_name'))
print(reports)


And I need help
-- 
*TUYIZERE Eugene*



*Msc Degree in Mathematical Science*

*African Institute for Mathematical Sciences (AIMS Cameroon)Crystal
Garden-Lime, Cameroon*

Bsc in Computer Science

*UR-Nyagatare Campus*

Email: eugene.tuyiz...@aims-cameroon.org
   eugenetuyiz...@gmail.com

Tel: (+250) 7 88 26 33 38, (+250) 7 22 26 33 38

-- 
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/CABxpZHstWyfMVKQhJb%3DxGKff3p3V%2BFQ_w3DkYVpOe-pEW2ySKg%40mail.gmail.com.