Skip to content

Fix mktemplate attribute error#85

Closed
mk11232 wants to merge 3 commits intocarltongibson:mainfrom
mk11232:fix-mktemplate-attribute-error
Closed

Fix mktemplate attribute error#85
mk11232 wants to merge 3 commits intocarltongibson:mainfrom
mk11232:fix-mktemplate-attribute-error

Conversation

@mk11232
Copy link

@mk11232 mk11232 commented Jun 19, 2025

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/app location.

Proposed Solution

I have a fix ready that:

  • Keeps current check if app/templates/app directory 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/--all option to generate all CRUD templates at once (new)
  • Updated tests to ensure coverage

Environment Tested

  • Django 5.2.3
  • Django 4.2.23
  • neapolitan 24.8

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.

mk11232 added 3 commits June 19, 2025 15:40
- 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
@mk11232 mk11232 closed this Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant