-
Notifications
You must be signed in to change notification settings - Fork 204
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
Move template files from templates
to templates/sqladmin
#748
Conversation
templates
to templates/sqladmin
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.
Thanks a lot for the contribution 👍
First, thanks all. I appreciate you. I understand why it may be desirable to move templates to a 'templates/sqladmin' folder, but am curious why you just don't initialize the package loader with the 'templates/sqladmin' like so:
then you wouldn't have to add the 'sqladmin' to the extends. For instance in index.html:
My point being, that if I have a custom 'layout.html', or other html file, that I want shared between sqladmin and another application (a directory that doesn't start with 'sqladmin') I can't do that then without overriding every other template file in the package that references 'sqladmin/layout.html'. But when the index.html file extends is as such:
the package loader would still be able to find 'templates/sqladmin/layout.html' but other loaders (in priority of choice before the package loader) would also be able to load a custom version of the file in whatever directories are in the loader's searchpath (ie 'templates/something_else/layout.html') without having to modify all of the other core template files accessed by the package loader. I feel the way this is implemented actually hinders customization, and reusability, of templates because if you want to use a single custom template that is not in a 'sqladmin' directory (possible because it's shared with other applications), you have to then modify/override every other template in the package that references it - and then manually edit each one of those every time changes are made to the sqladmin codebase or default templates when you could just be using the default package templates instead. I think this should be re-opened for discussion. Please let me know if this makes sense or if there is anything else I can do or provide to clarify my point. Thanks again. |
If you check out the problem at #747, you'll understand why we went in that direction.
You are right, there are some problems but they are going to be resolved when they are real pain in the ass (like Flask Admin). Here is a solution recommendation for your scenario: #762 (reply in thread) I also want to point out that this idea comes from Flask Admin, which has proved its reusability end extendibility. |
Thanks for the reply! I love this project because it stays as true to flask-admin as it can. After 'correctly' updating my custom admin code, directory structure, and templates, I have come to conclusion that I no longer have issues, and have made my peace, with this change. |
You're welcome 🙏.
I totally agree, I'm working on a Starlette adoption of Flask Admin, let me know if you are interested in, I'll share a link.
😂, happy to hear that. @flask-admin people did a lot of good design decisions, years of experience right?. Even though I don't understand some parts of its source code, I left them as is. They might know better! 🚀🚀🚀. |
Thanks for your project, first of all! I've faced an issue using a 0.19 version after 0.16.1. I could not just create templates folder, move there original package files and customize them a bit. Using templates_dir parameter doesn't help. Is there any way to achieve such goals like localisation and customisation? Thanks in advance. |
I think I didn't fully get your question. |
Because I'd like to use them with minimal changes)
This works fine for me, and now I successfully override base files. |
Yes that is correct. This was the intention of this PR to need |
I hope this clarifies what you said: #817 |
Closes #747
I ran the test suite, looking good 🚀.
I "visually" tested it with the example code from Working with Custom Views - SQLAlchemy Admin, works fine ☮️.