Closed
Conversation
- Replace Engine.template_dirs with settings.TEMPLATES[0]['DIRS'] - Create app templates directory if neither app nor project dirs exist - Add -a/--all option to generate all CRUD templates at once - Ensure subdirectories are created when generating templates Fixes AttributeError when app templates directory doesn't exist.
- Replace Engine.template_dirs with settings.TEMPLATES[0]['DIRS'] - Create app templates directory if neither app nor project dirs exist - Add -a/--all option to generate all CRUD templates at once - Ensure subdirectories are created when generating templates Fixes AttributeError when app templates directory doesn't exist.
…into fix-mktemplate-attribute-error # Conflicts: # src/neapolitan/management/commands/mktemplate.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug Description
The mktemplate command fails when there's no app-level templates directory already existing:
AttributeError: 'Engine' object has no attribute 'template_dirs'This happens as the command looks for a pre-existing
app/template/applocation.Proposed Solution
I have a fix ready that:
app/templates/appdirectory exists, if not then:-- Uses
settings.TEMPLATES[0]['DIRS']to see if project level templates exist (new)-- If neither exist, creates app-level templates directory (new)
-- Adds
-a/--alloption to generate all CRUD templates at once (new)Environment Tested
Note
Since you use app-level templates, this now auto-creates the
app/templates/app/structure when bootstrapping a new app - no more manual mkdir! Still respects project-level templates for those who prefer that approach.