Skip to main content

A single command to run everything you need for local Django development.

Forge work command example

The following processes will run simultaneously (some will only run if they are detected as available):

It also comes with debugging tools to make local debugging easier with VS Code.

Installation

Django + Forge Quickstart

If you use the Forge Quickstart, everything you need will be ready and available as forge work.

Install for existing Django projects

First, install forge-work from PyPI:

pip install forge-work

Then add it to your INSTALLED_APPS in settings.py:

INSTALLED_APPS = [
    ...
    "forgework",
]

Now instead of using the basic manage.py runserver (and a bunch of commands before and during that process), you can simply do:

python manage.py work

Development processes

Runserver

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.

forge-db

If forge-db is installed, it will automatically start and show the logs of the running database container.

forge-tailwind

If forge-tailwind is installed, it will automatically run the Tailwind compile --watch process.

package.json

If a package.json file is found and contains a watch script, it will automatically run. This is an easy place to run your own custom JavaScript watch process.

Stripe

If a STRIPE_WEBHOOK_PATH env variable is set then this will add a STRIPE_WEBHOOK_SECRET to .env (using stripe listen --print-secret) and it will then run stripe listen --forward-to <runserver:port/stripe-webhook-path>.

Ngrok

If an NGROK_SUBDOMAIN env variable is set then this will run ngrok http <runserver_port> --subdomain <subdomain>. Note that ngrok will need to be installed on your system already (however you prefer to do that).

Debugging

Since forge 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_data(self, **kwargs):
        context = super().get_context_data(**kwargs)

        # Make sure the debugger is attached (will need to be if runserver reloads)
        from forgework 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": "Forge: 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 "Forge: 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 forge-work 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for forge-work 0.4.0
File Size Uploaded Provenance Actions
forge-work-0.4.0.tar.gz 7.0 kB Without provenance Details for forge-work-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for forge-work 0.4.0
File Interpreter ABI Platform Actions
forge_work-0.4.0-py3-none-any.whl Python 3 none any Details for forge_work-0.4.0-py3-none-any.whl

Total release size: 15.0 kB

Release files / forge-work-0.4.0.tar.gz

Download URL forge-work-0.4.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5350cfc4c417fdd15ba8cfd3672f13c2ce87c4785c07e9cc61ee0a8097b9cdd9
BLAKE2b-256 checksum
How to use checksums
3919cd4f7fea61891c7d2c204ba2b7dae13b822c9c10f0740a8146c00aa79267
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.1 CPython/3.10.6 Linux/5.15.0-1019-azure

Release files / forge_work-0.4.0-py3-none-any.whl

Download URL forge_work-0.4.0-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
507b063a9b8752237a3427c1555c6303d0f538b52abeac1d68c3c9326388030f
BLAKE2b-256 checksum
How to use checksums
4b68e9416e51b0149d03ca203650be36432b99b92edd7dad29f9bda981507c10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.1 CPython/3.10.6 Linux/5.15.0-1019-azure

Security for forge-work 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page