Add template for deploying Django apps on Databricks Apps#185
Draft
tlgnr wants to merge 19 commits intodatabricks:mainfrom
Draft
Add template for deploying Django apps on Databricks Apps#185tlgnr wants to merge 19 commits intodatabricks:mainfrom
tlgnr wants to merge 19 commits intodatabricks:mainfrom
Conversation
…per directory Remove the `django-on-databricks-apps/` parent directory and promote `django-postgres-app/` to the top level. Move `databricks.yml` and `README.md` into the app directory and update internal references: - databricks.yml: source_code_path from `./django-postgres-app` to `.` - pyproject.toml: readme from `../README.md` to `README.md` - README.md: flatten project structure listing, remove `cd` step
The add view manually checked request.method while toggle and delete used the decorator. Replace the manual check with @require_POST for consistency -- GET requests now return a proper 405 instead of a silent redirect.
Set SESSION_COOKIE_SECURE and CSRF_COOKIE_SECURE to not DEBUG so cookies are transmitted over HTTPS only in production while still working over plain HTTP during local development.
Replace raw request.POST access with a TodoForm ModelForm for proper validation through Django's forms framework. The form widget carries the placeholder and required attributes so the template renders identically.
Only write the completed column instead of all fields, avoiding unnecessary database work and potential overwrites of concurrent changes to other fields.
All three auth functions (authenticate, login, logout) now share a single top-level import instead of logout being imported lazily inside the else branch. There is no circular import risk here.
Move the helper out of config/settings.py into utils.py so both settings and the ensure_schema management command import from a standalone module rather than coupling to the settings file directly.
Replace uvicorn and the ASGI entry point with gunicorn and a standard WSGI configuration. All views are synchronous so there is no benefit from an async server; gunicorn with sync workers is the conventional Django deployment and simplifies connection-pool reasoning.
Use Django's default of closing connections after each request. The Lakebase backend injects short-lived OAuth tokens, so persistent connections would go stale anyway. Closing per-request avoids that complexity with negligible overhead for this workload.
Add double-checked locking so concurrent threads cannot both create a WorkspaceClient. Reuses the existing _token_lock since the client is only initialised once and the lock is uncontended at that point.
Cast to float and document that expire_time is a protobuf Timestamp whose .seconds field gives Unix epoch seconds, matching time.time().
Align the package name with the directory name (django-postgres-app).
Accept common truthy values (true, 1, yes) regardless of case instead of requiring the exact string "True". Defaults to False when the environment variable is unset.
This keeps deployment docs aligned with the actual `entrypoint.sh` sequence so users run the expected `gunicorn`-based startup.
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.
This template deploys a simple Django todo app on Databricks Apps with Lakebase Autoscaling as the PostgreSQL database backend. It's designed to be familiar to Django developers, adding new code only where needed to interface with Databricks. The goal is for Django developers to get up and running quickly on Databricks.