Skip to content

Make mktemplate also work with project-level template directories#49

Open
haukuri wants to merge 3 commits intocarltongibson:mainfrom
haukuri:mktemplate-project-template-dir-fix
Open

Make mktemplate also work with project-level template directories#49
haukuri wants to merge 3 commits intocarltongibson:mainfrom
haukuri:mktemplate-project-template-dir-fix

Conversation

@haukuri
Copy link
Copy Markdown

@haukuri haukuri commented Jun 23, 2024

The mktemplate management command was not working for project-level template directories. See issue #48.

This change updates the mktemplate handle function to work for both app and project template directories.

@haukuri
Copy link
Copy Markdown
Author

haukuri commented Jun 23, 2024

@carltongibson I couldn't quite figure out how to make the test case for not using an app-level template directory work with the existing unit test structure so I refactored it to more closely resemble a project structure as generated by startproject and startapp.

Would you rather keep the existing structure?

If so, could you point me in the right direction towards how to implement the new test within it?

@haukuri haukuri changed the title Mktemplate project template dir fix Make mktemplate also work with project-level template directories Jun 23, 2024
@carltongibson
Copy link
Copy Markdown
Owner

Hi @haukuri.

Would you rather keep the existing structure?

I would 😅

Could you not (merely) add an extra_templates folder? (This wouldn't be auto-detected by app-level finder, so would need to be added to the settings)

@haukuri haukuri force-pushed the mktemplate-project-template-dir-fix branch from 27f730a to 081cab3 Compare July 7, 2024 00:52
@haukuri
Copy link
Copy Markdown
Author

haukuri commented Jul 7, 2024

Hi @carltongibson

The current version renames the template directory in the test project so that it does not get picked up as an app template dir. This is not great because now we are not testing the case in which the user is actually using an app template dir.

I've also tried to use the @override_settings decorator on the test method to disable app template directories and specify an extra_templates dir for a specific test but that did not work.

I've even tried having both the regular app templates directory and an extra_templates directory and temporarily renaming the templates dir while running mktemplate but that just resulted in upsetting the template loader.

A solution would be to have a second app in the test project that would not have a template directory so that we would fall back to the project level template dir but I'm not sure how to do that within the test project structure.

Perhaps we should just close this PR. You could always do the change to mktemplate at some later point if interested.

@carltongibson
Copy link
Copy Markdown
Owner

@haukuri Let me have a play. Thanks. 🙏

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.

2 participants