plain-dev
A single command to run everything you need for local Plain development.
The plain dev command runs a combination of local commands + a Docker container for your database.
The following processes will run simultaneously (some will only run if they are detected as available):
Installation
pip install plain-dev
If you have plain-models installed (i.e. you're using a database),
then add DATABASE_URL to your .env file.
DATABASE_URL=postgres://postgres:postgres@localhost:54321/postgres
# pyproject.toml
[tool.plain.dev.services]
postgres = {cmd = "docker run --name app-postgres --rm -p 54321:5432 -v $(pwd)/.plain/dev/pgdata:/var/lib/postgresql/data -e POSTGRES_PASSWORD=postgres postgres:15 postgres"}
plain dev
plain dev
Default processes
- plain preflight
- gunicorn
- migrations
- tailwind
Custom processes
- package.json "dev" script
- pyproject.toml
tool.plain.dev.run = {command = "..."}
GitHub Codespaces
The BASE_URL setting is automatically set to the Codespace URL.
TODO
plain dev db
Only supports Postgres currently.
- snapshot
- import
- export
Development processes
Gunicorn
The key process here is still manage.py runserver.
But, before that runs, it will also wait for the database to be available and run manage.py migrate.
plain-models
If plain-models is installed, it will automatically start and show the logs of the running database container.
plain-tailwind
If plain-tailwind is installed, it will automatically run the Tailwind compile --watch process.
Debugging
Since plain work runs multiple processes at once, the regular pdb debuggers can be hard to use.
Instead, we include microsoft/debugpy and an attach function to make it even easier to use VS Code's debugger.
First, import and run the debug.attach() function:
class HomeView(TemplateView):
template_name = "home.html"
def get_context(self, **kwargs):
context = super().get_context(**kwargs)
# Make sure the debugger is attached (will need to be if runserver reloads)
from plain.work import debug; debug.attach()
# Add a breakpoint (or use the gutter in VSCode to add one)
breakpoint()
return context
When you load the page, you'll see "Waiting for debugger to attach...".
Add a new VS Code debug configuration (using localhost and port 5768) by saving this to .vscode/launch.json or using the GUI:
// .vscode/launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Plain: Attach to Django",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
],
"justMyCode": true,
"django": true
}
]
}
Then in the "Run and Debug" tab, you can click the green arrow next to "Plain: Attach to Django" to start the debugger.
In your terminal is should tell you it was attached, and when you hit a breakpoint you'll see the debugger information in VS Code. If Django's runserver reloads, you'll be prompted to reattach by clicking the green arrow again.
Metadata
Release files for plain.dev 0.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| plain_dev-0.0.0.tar.gz | 16.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| plain_dev-0.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.8 kB
Release files / plain_dev-0.0.0.tar.gz
| Download URL | plain_dev-0.0.0.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
18941b06e0019dd4a899d86c512e6be036b01e173509843f16f4d7617842e246
|
|
BLAKE2b-256 checksum How to use checksums |
dc1444d6f8249f570abdf8f8db994a5e13ca8e77ec28612e3e32138d4f438348
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.12.0 Darwin/23.5.0
|
Release files / plain_dev-0.0.0-py3-none-any.whl
| Download URL | plain_dev-0.0.0-py3-none-any.whl |
|---|---|
| Size | 22.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f8917f0639acf7d61c66714d774c23421f685a285b89caf7abb99b95a2011152
|
|
BLAKE2b-256 checksum How to use checksums |
6178c7e8f0a6e4138310c1e7eb0096f3dfff57694ba40d476d0e3e726556d381
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.12.0 Darwin/23.5.0
|