Skip to main content

Frontly

The easiest way to build views for Django. Without building any views!

Frontly allows you to make front-end changes to text and images without building custom views or using the admin. It can edit any field the ORM has access to. For example:

{% load frontly %}

<!-- Please see https://htmx.org/docs/#installing about the recommended way to install HTMX -->
<script src="https://unpkg.com/htmx.org@1.9.6" integrity="sha384-FhXw7b6AlE/jyjlZH5iHa/tTe9EpJ1Y55RjcgPbjeWMskSxZt1v9qkxLJWNJaGni" crossorigin="anonymous"></script>

<!-- This replaces {{ author.name }} -->
<h1>{% fr_input request.user instance=author field="name" default="Jordan Doe"%}<h1>

This will display what's in auther.name by default and, if you have the correct permissions, it will allow you to double-click and edit the field.

INSTALLATION 🚀

You can install Frontly by using pip:

$ pip install django-frontly

Then add this to your settings.py:

INSTALLED_APPS = (
    ...
    'frontly',
)

And add this to your main urls.py:

urlpatterns = [
    ...
    path('frontly/', include('frontly.urls', namespace='frontly')),
]

CONFIGURATION ⚙️

You can add these to you settings file.

FRONTLY_CHECK_KILLSWITCH_PERM = True  # default

If FRONTLY_CHECK_KILLSWITCH_PERM is True (default), it will check to see if the user has the permission frontly.frontly_killswitch. If the permission is missing, they will not be able to make changes in the front-end.

You will want to temporarily set to False while testing only.

By default all input is sanitized using nh3. You can disable this by settings FRONTLY_SANITIZE to False in your settings.py.

USAGE

Using Frontly in your existing application is designed to be very simple. It's template tags are designed to be a drop-in replacement, where you would normally output the context variable in your template.

Two things to keep in mind are:

  • Always include HTMX in your template. You can do this in a base template if you are using it everywhere.
  • Always include {% load frontly %} to get access to the frontly tags.

The template tags currently available are: fr_input, fr_textarea, fr_img. PRs for additional editing widgets are welcome.

EXAMPLES

{% fr_img request.user instance=user_profile field="profile_pic" class="border-radius" alt=user_profile.name default=user_profile.get_profile_pic_url %}

fr_img example:

  • request.user - used to check permissions.
  • instance - the django model instance you are working on.alt
  • field - the name of the field within the model. Note that you can have a JSONField and refer to a value deep within the json. i.e. user.misc_json.key
  • default - A default value to display if the field is null.

Anything else passed to the template tag will passed directly to the html field. In this example class is passed directly to the field.

SECURITY

Row level security is handled by model_instance.frontly_permission_check(). Returning True will allow the editing to happen.

Add this to your models:

    def frontly_permission_check(self, user):
        """ Check if a certain user has permission to do this.
        """
        return self.user == user

FEATURES

  • Allow for simple front-end editing.
  • Built-in support for input, textarea and image types.
  • Ability to customize additional editor types.
  • Row level security

CONTRIBUTING

We welcome PRs for new editor types and new features. If you get stuck, please open an issue so that we can improve the documentation.

If you find a bug 🐛, please open a bug report. If you have an idea for an improvement or new feature 🚀, please open a feature request.

AUTHORS & ACKNOWLEDGEMENTS

  • Ed Menendez
  • The HTMX Project
  • Trix Project

LICENSE

This project is licensed under the MIT License

MIT License

Copyright (c) 2023 Ed Menendez

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for django-frontly 1.0.4

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

Source distribution (sdist)

Source distribution for django-frontly 1.0.4
File Size Uploaded
django-frontly-1.0.4.tar.gz 128.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-frontly 1.0.4
File Interpreter ABI Platform
django_frontly-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 262.2 kB

Release files / django-frontly-1.0.4.tar.gz

Download URL django-frontly-1.0.4.tar.gz
Size 128.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a9a8346f9dc5d87dedc0fffe9a42fd4eca62dd901323767db847a90774b766cf
BLAKE2b-256 checksum
How to use checksums
2d75d5768f5cc14e35333ca83cbee5bc289a69415bcd1cd39e5c22727bcabfb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / django_frontly-1.0.4-py3-none-any.whl

Download URL django_frontly-1.0.4-py3-none-any.whl
Size 134.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
29bcbdb1a53b1b41f3e74d02ce5698c37d08509f3b963e3221bd9b491a17065f
BLAKE2b-256 checksum
How to use checksums
69baf6d6bccca3e8e84bfd129253abb1db815c995682d74048a014fdc2855a04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 release files

1.0.3

2 release files

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