Skip to main content

Django Unfold admin integration for django-fobi

Project description

django-unfold-fobi

PyPI - Version Build

Introduction

django-unfold-fobi integrates django-fobi into django-unfold. It provides an Unfold-native admin experience for managing Fobi forms, plus a small compatibility and patch layer for modern Django/DRF stacks.

Intention

This package is an integration layer, not a replacement for standalone Fobi usage. You can still use standard Fobi public forms and existing plugins; this project focuses on making the admin and integration surface fit naturally into Unfold-based back offices.

Features

  • Unfold-native admin integration for Fobi form management.
  • Unfold widget styling applied across Fobi admin/plugin form surfaces.
  • DRF-oriented improvements for Fobi API submissions and handler behavior.
  • Admin workflow enhancements (import/clone/popup behavior, staff editing).
  • Optional Sites extension (unfold_fobi.contrib.sites) for site-scoped forms, queryset scoping, and reusable admin mixins.

Requirements

  • Python >=3.10,<4.0
  • Django >=5.0
  • django-unfold >=0.80.0
  • django-fobi >=0.19
  • django-crispy-forms >=2.0
  • djangorestframework >=3.14
  • django-unfold-modal >=0.1.0

Patches & Compatibility

unfold_fobi applies a few startup patches to keep Fobi integration stable on newer dependency versions:

  • DRF compatibility shim restores rest_framework.fields.set_value for DRF 3.15+ where Fobi still expects it.
  • DRF db_store improvements include active-date enforcement and safer integration behavior.
  • Admin patches align popup/modal responses with Unfold workflows.
  • Additional Fobi patches improve widget consistency, staff editing behavior, and mail sender handler field handling.

Limitations

  • Main focus is DRF + admin integration; this package does not try to redesign every standalone Fobi rendering path.
  • For REST-based usage, you need to implement your own frontend form rendering using the API metadata returned for each form.
  • Non-Unfold form rendering should still work, but may not be styled like Unfold unless your project applies matching templates/styles.
  • Form wizards are currently linked/redirected, but not fully covered as a first-class Unfold-integrated workflow.

Quickstart

Install and enable the integration with minimum settings.

  1. Install package:
pip install django-unfold-fobi
  1. Add apps (order matters):
INSTALLED_APPS = [
    "unfold",  # must be before django.contrib.admin
    "crispy_forms",
    "fobi.contrib.themes.simple",
    "unfold_fobi",
]
  1. Add required template hooks:
TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [],
        "APP_DIRS": True,
        "OPTIONS": {
            "context_processors": [
                "django.template.context_processors.request",
                "fobi.context_processors.theme",
                "unfold_fobi.context_processors.admin_site",
            ],
            "builtins": [
                "unfold_fobi.templatetags.unfold_fobi_tags",
            ],
        },
    },
]
  1. Enable theme settings:
FOBI_THEME = "unfold"
FOBI_DEFAULT_THEME = "unfold"

CRISPY_TEMPLATE_PACK = "unfold_crispy"
CRISPY_ALLOWED_TEMPLATE_PACKS = ["unfold_crispy"]
  1. Add URLs (keep admin/fobi/ before admin.site.urls):
from django.urls import include, path

urlpatterns = [
    path("api/", include("fobi.contrib.apps.drf_integration.urls")),
    path("api/", include("unfold_fobi.api.urls")),
    path("fobi/", include("unfold_fobi.urls.public")),
    path("admin/fobi/", include("unfold_fobi.urls.admin")),
]
  1. Run migrations:
python manage.py migrate

Comprehensive Installation Guide

Use this when you need the full integration, including optional Sites support.

1) Install and baseline setup

  • Follow standard django-fobi installation first (plugins, handlers, base settings).
  • Then add unfold_fobi and the Quickstart settings from above.

2) Optional Sites integration

Enable only if your project needs form-to-site bindings.

INSTALLED_APPS += [
    "django.contrib.sites",
    "unfold_fobi.contrib.sites",
]

SITE_ID = 1
UNFOLD_FOBI_SITES_FOR_USER = "myproject.site_permissions.sites_for_user"

Then re-register your form admins with the mixins from unfold_fobi.contrib.sites.admin:

  • SiteAwareFormEntryMixin
  • RelationSiteScopeAdminMixin

These provide site assignment UI, queryset scoping, and reusable site-scoped permission helpers. Your project still owns user-to-site policy and project-specific permission decisions.

3) DRF notes

  • Include both Fobi DRF URLs and unfold_fobi.api.urls.
  • Use GET /api/fobi-form-fields/<slug>/ to fetch per-form field metadata (including available field types/widgets/choices) for frontend rendering.
  • Ensure each form has the db_store handler enabled for persisted API submissions.

Notes

  • unfold_fobi.apps.UnfoldFobiConfig.ready() runs during Django app startup and performs integration bootstrap in this order: DRF compatibility shim, Fobi admin re-registration for Unfold, monkey-patches, and signal registration.
  • If you want explicit app config wiring, use this in INSTALLED_APPS:
INSTALLED_APPS = [
    # ...
    "unfold_fobi.apps.UnfoldFobiConfig",
]
  • Startup signals auto-attach a db_store handler to saved forms and deduplicate duplicates created during JSON import.
  • The Unfold theme for Fobi is registered as uid="unfold".

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_unfold_fobi-0.1.7.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_unfold_fobi-0.1.7-py3-none-any.whl (70.3 kB view details)

Uploaded Python 3

File details

Details for the file django_unfold_fobi-0.1.7.tar.gz.

File metadata

  • Download URL: django_unfold_fobi-0.1.7.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for django_unfold_fobi-0.1.7.tar.gz
Algorithm Hash digest
SHA256 86abe125359c3979a2425ec50883c74f633964225d478a1bb7bb578154f4d9ab
MD5 64f711a54a80d24cb8b498ed2b8bfe7c
BLAKE2b-256 505add530ca5c5c13694f5e6876338dbe6207ee28e20436bd0a810eb38e8b853

See more details on using hashes here.

File details

Details for the file django_unfold_fobi-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for django_unfold_fobi-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 edb5624a49ffd41b5e1e20d6cae59fc037d3827f623d45ec04768d772e732a1a
MD5 c992635160aca040f7d4d60ed4ce5c1a
BLAKE2b-256 76aaba10a4aa44eae2841eaf6b48bbe94f571b31e81e026d38b74b57f3092fb8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page