Skip to content
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

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

haukuri
Copy link

@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
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
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
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
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