thank you so much for your ideas , I am gonna fix this ^^

Le mardi 26 mai 2020 01:01:17 UTC+1, Samuel Nogueira a écrit :
>
> Hi! before answer you question I would recomend you to give a little fix 
> in your model and your function names. Try to follow the PEP8 style guide 
> for Python, in the guide is recommended using only capitalized words for 
> naming classes with composite names, and function names should be lowercase 
> with words separated by underscore. Thereby, would be more appropriate 
> naming your function and class this way: *class 
> MailItemCountDeliveriesPerDate()* and *def json_deliv()*. Fell free to 
> accept or ignore this tip.
>
> Now, back to the question, the DateTimeField() is a implementation of the 
> python datetime.datetime for storage in the database, so after you get the 
> Date from the database you can use the timestamp() method in the related 
> Date field. This will deliver the date in seconds format, then you just 
> multiply by 1000 to get your Date in milliseconds.
>
>  
>
> Hope this helps. Sorry if it got a little confusing.
>
>  
>
> *De: *HJ <javascript:>
> *Enviado:*segunda-feira, 25 de maio de 2020 19:17
> *Para: *Django users <javascript:>
> *Assunto: *convert Date to milliseconds
>
>  
>
> Hello everyone I want to convert my Date from string to *milliseconds*
>
>  
>
> this is my *models.py class *
>
>  
>
> *class* mail_item_count_deliveries_perDate(*models*.*Model*):
>
>    countDeliveries = models.IntegerField(*default*=0)
>
>    Date = models.DateTimeField()
>
>  
>
> this is my *views.py *
>
>  
>
> *def* jsonDeliv(*request*):
>
>  
>
>  dataset = mail_item_count_deliveries_perDate.objects.all().values_list(
> 'Date','countDeliveries')
>
>  data = *list*(dataset)
>
>  
>
>  return JsonResponse(data, *safe*=False)
>
>
> this is how the data looks like 
>
>  
>
> [["2020-05-21T00:00:00Z", 5], ["2019-05-21T00:00:00Z", 1], 
> ["2020-04-06T00:00:00Z", 3], ["2020-02-10T00:00:00Z", 2], 
> ["2020-01-23T00:00:00Z", 4],
>
>
> I want to convert the Date to milliseconds I want to use it in stock 
> highchart , and I don't know how to do it here can you guys help me please 
>
> -- 
> 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...@googlegroups.com <javascript:>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/de8d3e67-2a68-45be-a9c9-fb06fbb206a6%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/de8d3e67-2a68-45be-a9c9-fb06fbb206a6%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>  
>

-- 
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/9ea6d735-c752-4572-9f55-e0de4bdf3439%40googlegroups.com.

Reply via email to