Repository navigation
Add a Django project creator to Create New Project from Template - #2061
Open
Ming (MaxonT) wants to merge 1 commit into
Open
Ming (MaxonT) wants to merge 1 commit into
Ming (MaxonT) wants to merge 1 commit into
Conversation
Signed-off-by: Ym <173550318+MaxonT@users.noreply.github.com>
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.
NewDjangoProject is added here for #394, modeled on the package and script creators; a project it generates passes manage.py check, but I only tried it with Django 6.1.3, so older versions are untested.
Fixes #394
Thanks to eleanorjboyd for opening this one; the package and script creators made it straightforward to follow. This adds a
NewDjangoProjectcreator next to them and registers it inextension.ts, so Django shows up in Python Envs: Create New Project from Template. Thepython-djangoproject type is also mapped in the quick create path ofpython-envs.createNewProjectFromTemplate.What it creates, for a project named
mysite:mysite_project/withmanage.py,requirements.txt(justdjango) and amysite/package holdingsettings.py,urls.py,asgi.pyandwsgi.py. It is the minimal layoutdjango-admin startprojectproduces, filled from a template folder the same way the package template is. Each project gets its own freshly generatedSECRET_KEY. The name is validated as a plain Python identifier anddjango,testand Python keywords are refused. If copying or registering the project fails, the half created folder is removed and the error is rethrown. README anddocs/managing-python-projects.mdlist the new type.I left out virtual environment creation and Copilot instructions on purpose to keep this first version small: the creator copies the template, registers the project and opens
manage.py. Happy to add the venv prompt the package creator has if you want it. The open Flask (#2060) and FastAPI (#2020) PRs register their creators on the same lines ofextension.ts, so whichever lands second may need a small rebase.Tests:
src/test/features/creators/newDjangoProject.unit.test.tshas 9 tests (name validation, template contents, created layout and name substitution, unique secret keys, quick create errors, existing folder, rollback, workspace fallback and prompt, dismissed prompt). The full unit suite passes (3220 passing, 7 pending, up from 3211 before the change; Node 22, macOS),eslintis clean on the new files, and disabling the secret key replacement makes 2 of the new tests fail. I also generated a project from the template, filled in a name and key by hand, and ranpython manage.py checkwith Django 6.1.3 in a fresh venv: no issues.Not run: the smoke, integration and e2e suites (they need a VS Code download), and I did not try the command inside a running VS Code window. I grepped the text-complete checkout only.