New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for global date formats and fixed drf date formats not supported #50
Conversation
- added global date format settings - added support for rest framework date formats
@rptmat57 @willtho89 Thanks for the contribution! Before we review and merge this, I want to raise a question that's been on my mind. Do we want to rename this package something less... obtuse? Like That way, the prefix for settings could be I'm not married to the current package name and figured we should have the conversation before we create global settings, to avoid headaches for people down the road. |
That's probably a good time to have that discussion. Jokes aside, the current name doesn't bother me. it's pretty explicit and does what it says. Just my 2 cents. |
Current name also doesn't bother me, but I can see where you are coming from. Other Packages mostly use I would leave this up to you @FlipperPA |
lgtm @rptmat57 when we decide on a name please also update README.md briefly explaining these settings |
sure thing. I'll update the README With regards to settings, what do you think about having them inside REST_FRAMEWORK? |
Let me bounce these questions off Tom Christie and a few others, since we're playing in that ecosystem. :) Great work, my friends. If you want to follow on Twitter: https://twitter.com/FlipperPA/status/1493772563645927427 |
- added custom date format - added custom number format - global date and number formats can also be set
- added global boolean_display option
Awesome work @rptmat57. Using cell formatting is a great feature generally. I'm not sure how we handle breaking changes. Imo Deprecation warnings would be best. @FlipperPA what would you suggest? |
Deprecation warnings would be best - and I think we're probably around time for a 1.0 release and |
lgtm – aside from the new datetime formatting. tested with some of our existing data/serializers. Had to rewrite the |
would supporting both formats using a |
Actually, nevermind. I would suggest that we could now use one format dictionary where both date and number formats could be defined. It would make things much easier. all following openpyxl formats |
something like this:
|
@rptmat57 @willtho89 Renaming is complete! I ended up going with You should be able to |
- combined date/time and number formatting into one dictionary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be done with changes now
@rptmat57 This is looking really impressive. Thanks for putting so much effort in! |
@FlipperPA thanks! I am hoping it will make dealing with formatting easier, and it will be very useful to me so it's a win-win. |
- added ability to set style per column data
alright I am really done now. added styling/formatting per column |
@rptmat57 @willtho89 I'm good with merging this as long as you both are. Does this break backwards compatibility? Should this become released version 2.0.0? We'll never get SemVer perfect, I'm sure, but should do our best. :) |
it does break backwards compatibility with regards to date formats. |
No biggie at all! I wanted the 1.0 release to be the name change, so 2.0 is just fine. |
When will version 2.0 with code written by rptmat57 be released? I was watching this conversation because I needed the number format function. |
@LeeHanYeong I'm going to get it out the door shortly. Today. :) |
Great work @rptmat57! Thanks so much, this is a major improvement. We are live! |
#49
Changes:
This was a bit more complicated than I originally thought because the data is already formatted by drf, and because we needed to know the field type (couldn't rely on the type since it was a str).
I realized the current version would break when using drf's
DATETIME_FORMAT
,DATE_FORMAT
orTIME_FORMAT
because parse_datetime() and parse_date() could not parse non-iso formats.Take a look and let me know what you think.
Also what should the settings be name and where should they be?
I went with
DRF_RENDERER_XLSX_
prefix in global django settings:DRF_RENDERER_XLSX_DATETIME_FORMAT
DRF_RENDERER_XLSX_DATE_FORMAT
DRF_RENDERER_XLSX_TIME_FORMAT
Another option would be to stick these settings inside
REST_FRAMEWORK = {}
instead?