> Den 21. sep. 2016 kl. 02.41 skrev sum abiut <suabiut@gmail.com>:
>
> Thanks Erik,
>
> i think that should do the trick.is there a way to covert the date column straight from the sql query or from the template?
If you want to do this from the template, create a custom template tag: https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/
I don't have experience with MSSQL, but if you want to convert the date server-side, this should work: http://blogs.msmvps.com/robfarley/2009/03/25/converting-to-and-from-julian-format-in-t-sql/ You could add the custom SQL as a RawSQL: https://docs.djangoproject.com/el/1.10/ref/models/expressions/#django.db.models.expressions.RawSQL
Depending on how your data is represented, you could also solve this with a custom model field: https://docs.djangoproject.com/en/1.10/howto/custom-model-fields/ The conversion code should go in the from_db_value() method.
Erik
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5FA21E07-B29C-4036-BD7C-9F2DC30993AA%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment