Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Add a Django project creator to Create New Project from Template - #2061

Open
Ming (MaxonT) wants to merge 1 commit into
microsoft:mainfrom
MaxonT:contrib/394-auto
Open

Ming (MaxonT) wants to merge 1 commit into
microsoft:mainfrom
MaxonT:contrib/394-auto

Conversation

@MaxonT

Copy link
Copy Markdown

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 NewDjangoProject creator next to them and registers it in extension.ts, so Django shows up in Python Envs: Create New Project from Template. The python-django project type is also mapped in the quick create path of python-envs.createNewProjectFromTemplate.

What it creates, for a project named mysite: mysite_project/ with manage.py, requirements.txt (just django) and a mysite/ package holding settings.py, urls.py, asgi.py and wsgi.py. It is the minimal layout django-admin startproject produces, filled from a template folder the same way the package template is. Each project gets its own freshly generated SECRET_KEY. The name is validated as a plain Python identifier and django, test and Python keywords are refused. If copying or registering the project fails, the half created folder is removed and the error is rethrown. README and docs/managing-python-projects.md list 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 of extension.ts, so whichever lands second may need a small rebase.

Tests: src/test/features/creators/newDjangoProject.unit.test.ts has 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), eslint is 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 ran python manage.py check with 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.

Signed-off-by: Ym <173550318+MaxonT@users.noreply.github.com>
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.

New Project: Django

1 participant