Closed PetrDlouhy closed 6 months ago
@danirus This PR is very small and simple. Are there any obstacles that are preventing it from being merged?
Hi @PetrDlouhy, sorry for my late reply since you submitted it.
I would like to know what is the use case you have in mind to add that extra field.
Why having submit_date
is not enough?
I am feeding that information to dayjs and the problem is, that submit_date
is more human readable format and doesn't contain some information - especially the timezone.
You could modify your DATETIME_FORMAT
setting to have in the submit_date
field the content you need.
You could modify your
DATETIME_FORMAT
setting to have in thesubmit_date
field the content you need.
There is an issue in the method get_submit_date
of ReadCommentSerializer
. It has to read the value of settings.DATETIME_FORMAT
, instead of passing the string DATETIME_FORMAT
. When resolved you could define the format you need in your settings module.
It is fixed in master
. It will be fixed in 2.9.12 later today.
The idea is to use settings.DATETIME_FORMAT
to adapt the submit_date
to your project.
Does that mean, that I have to change DATETIME_FORMAT
in my entire project?
That sounds like hundred unexpected consequences to me. And I also want to keep DATETIME_FORMAT
in human readable format in all other places except API, where should always be computer readable format in my opinion.
Or is there a way to change DATETIME_FORMAT
just for django-comments-xtd
?
It could work that way too. A new setting COMMENTS_XTD_API_DATETIME_FORMAT
would default to DATETIME_FORMAT
. If we want the API to use a specific datetime format for the submit_date
in the ReadCommentSerializer
, then we can provide COMMENTS_XTD_API_DATETIME_FORMAT
.
I added OrderingFilter to the comments API to enable sorting by particular fields. I also added
submit_date_timestamp
to be able to sort by date and it could be also helpful to determine the exact time in some applications (assubmit_date
is dependend on server timezone).