Skip to main content

Provides support forms for your application.

Project description

plain.support

Provides support forms for your application.

Overview

You can add support forms to your application to collect user feedback, bug reports, and other messages. When a form is submitted, an email is sent to your support team.

# app/urls.py
from plain.urls import include, path, Router
from plain.support.urls import SupportRouter


class AppRouter(Router):
    namespace = "app"
    urls = [
        path("support/", include(SupportRouter)),
        # ...
    ]
# app/settings.py
SUPPORT_EMAIL = "support@example.com"

This creates a support form at /support/form/default/ that users can fill out. When submitted, an email is sent to your SUPPORT_EMAIL address with the user's name, email, and message.

Configuration

Settings

  • SUPPORT_EMAIL (required): The email address where support requests are sent
  • SUPPORT_FORMS: A dictionary mapping form slugs to form classes (defaults to {"default": "plain.support.forms.SupportForm"})

Custom forms

You can create custom support forms by extending SupportForm. The form uses ModelForm from plain.models.forms.

# app/forms.py
from plain.support.forms import SupportForm
from plain.support.models import SupportFormEntry
from plain import forms


class BugReportForm(SupportForm):
    browser = forms.CharField(max_length=100, required=False)

    class Meta:
        model = SupportFormEntry
        fields = ["name", "email", "message", "browser"]

Then register it in your settings:

# app/settings.py
SUPPORT_FORMS = {
    "default": "plain.support.forms.SupportForm",
    "bug-report": "app.forms.BugReportForm",
}

The form will be available at /support/form/bug-report/.

You can also customize the email notification by overriding the notify method:

class BugReportForm(SupportForm):
    # ...

    def notify(self, instance):
        # Send to a different channel, create a ticket, etc.
        pass

Views

You can use the following views for different scenarios:

Embedded forms

Support forms can be embedded in other sites using an iframe:

<iframe src="https://example.com/support/form/default/iframe/" width="100%" height="600"></iframe>

Or using the provided JavaScript embed:

<div id="support-form"></div>
<script src="https://example.com/support/form/default.js"></script>

Security considerations

Most support forms allow users to type in any email address. Be careful, because anybody can pretend to be anybody else. Conversations either need to continue over email (which confirms they have access to the email account), or include a verification step (emailing a code to the email address, for example).

The SupportForm.find_user() method attempts to associate entries with existing users by email, but this does not confirm the submitter's identity.

FAQs

How do I customize the form templates?

You can override the default templates by creating your own templates at:

  • support/page.html: The full page template
  • support/iframe.html: The iframe-friendly template
  • support/forms/<form_slug>.html: The form rendering template
  • support/success/<form_slug>.html: The success message template

How do I view support form entries?

Support form entries are stored in the SupportFormEntry model. You can query them directly or use the admin interface if you have plain.admin installed with the SupportFormEntryAdmin registered.

Can I associate support entries with logged-in users?

Yes. When a user is logged in, the form automatically associates the entry with their account. If the user is not logged in (common with iframe embeds), the form will try to find an existing user by email address using find_user().

Installation

Install the plain.support package from PyPI:

uv add plain.support

Add plain.support to your INSTALLED_PACKAGES in app/settings.py:

# app/settings.py
INSTALLED_PACKAGES = [
    # ...
    "plain.support",
]

Set the required SUPPORT_EMAIL setting:

# app/settings.py
SUPPORT_EMAIL = "support@example.com"

Include the support URLs in your app's URL configuration:

# app/urls.py
from plain.urls import include, path, Router
from plain.support.urls import SupportRouter


class AppRouter(Router):
    namespace = "app"
    urls = [
        path("support/", include(SupportRouter)),
        # ...
    ]

Run migrations to create the SupportFormEntry table:

uv run plain migrate

Create the required templates. At minimum, you need a form template:

<!-- app/templates/support/forms/default.html -->
{{ form.as_fields }}
<button type="submit">Send message</button>

And a success template:

<!-- app/templates/support/success/default.html -->
<p>Thank you for your message! We'll get back to you soon.</p>

You also need to create an email template for notifications. See the plain.email package for template setup instructions:

<!-- app/emails/support_form_entry.html -->
<p>New support request from {{ support_form_entry.name }} ({{ support_form_entry.email }})</p>
<p>{{ support_form_entry.message }}</p>

Visit /support/form/default/ to see your support form.

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

plain_support-0.30.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

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

plain_support-0.30.0-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file plain_support-0.30.0.tar.gz.

File metadata

  • Download URL: plain_support-0.30.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for plain_support-0.30.0.tar.gz
Algorithm Hash digest
SHA256 2dc4288ab8419cea4e3e38d843ed0f7707882e6c81fabb940d6c96a896770639
MD5 3306c6f1443b29a54698265501b148f5
BLAKE2b-256 264a7641e972e836b380e968c5753a5c9477a4f898f207ad4c7b8324818a0b0c

See more details on using hashes here.

File details

Details for the file plain_support-0.30.0-py3-none-any.whl.

File metadata

  • Download URL: plain_support-0.30.0-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for plain_support-0.30.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1117a063502f6f7a374e6779eb7b3bb5356e3f889152712b66e7a1af1188bf20
MD5 2aeec7f559e3801a68faa2050324394c
BLAKE2b-256 5f7f1a986b04886eabedfa804926db4ea8687c98668f676945e89006e838c5e1

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