{"id":15354582,"url":"https://github.com/timonweb/wagtail-non-admin-draftail","last_synced_at":"2025-09-10T13:32:53.856Z","repository":{"id":41922069,"uuid":"228602379","full_name":"timonweb/wagtail-non-admin-draftail","owner":"timonweb","description":null,"archived":false,"fork":false,"pushed_at":"2023-06-23T20:13:32.000Z","size":2996,"stargazers_count":19,"open_issues_count":7,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T16:51:17.608Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timonweb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-17T11:32:01.000Z","updated_at":"2024-11-05T15:05:09.000Z","dependencies_parsed_at":"2024-10-16T03:01:08.452Z","dependency_job_id":"6b9693e4-723d-4383-a998-3be80f206006","html_url":"https://github.com/timonweb/wagtail-non-admin-draftail","commit_stats":{"total_commits":41,"total_committers":6,"mean_commits":6.833333333333333,"dds":0.2195121951219512,"last_synced_commit":"4fce1693e3f525479666b485385e09d53c943c73"},"previous_names":["timonweb/non-admin-draftail"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timonweb%2Fwagtail-non-admin-draftail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timonweb%2Fwagtail-non-admin-draftail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timonweb%2Fwagtail-non-admin-draftail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timonweb%2Fwagtail-non-admin-draftail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timonweb","download_url":"https://codeload.github.com/timonweb/wagtail-non-admin-draftail/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248553969,"owners_count":21123557,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T12:19:54.442Z","updated_at":"2025-09-10T13:32:53.812Z","avatar_url":"https://github.com/timonweb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Non-admin Draftail\n\nWagtail has an excellent WYSIWYG editor called Draftail. Unfortunately, the editor can only be used on admin pages. But what if you want to use it on non-admin pages, such as Django form view pages?\n\nThis is where Non-admin Draftail comes to the rescue! The package provides all the necessary magic to set Draftail free from Wagtail admin and make it usable with a regular Django form that doesn't belong to the CMS admin interface. The only requirement is, of course, to have Wagtail installed.\n\n# Compatibility\nThe current version of the package is compatible with Wagtail v7+.\n\n# Installation\n1. Install the package from PyPI: `pip install wagtail_non_admin_draftail`\n2. Add `wagtail_non_admin_draftail` to `INSTALLED_APPS`:\n    ```python\n    INSTALLED_APPS = [\n        ...\n        'wagtail_non_admin_draftail',\n    ]\n    ```\n3. Add the following line to the main `urls.py` of the project:\n    ```python\n    path(\"non-admin-draftail/\", include(\"wagtail_non_admin_draftail.urls\", namespace=\"wagtail_non_admin_draftail\")),\n    ```\n4. Include `\"wagtail_non_admin_draftail/draftail_media.html\"` in the `\u003chead\u003e` of every page that will have the editor.\n   There are many ways to do this. Here is one way to accomplish it:\n\n    a. Add the `{% block wagtail_non_admin_draftail_head %}` block to the `\u003chead\u003e` of your `base.html` file:\n\n    ```html\n    {% load wagtail_non_admin_draftail_tags %}\n    \u003c!DOCTYPE html\u003e\n    \u003chtml\u003e\n    \u003chead\u003e\n     ...\n     {% block wagtail_non_admin_draftail_head %}{% endblock wagtail_non_admin_draftail_head %}\n    \u003c/head\u003e\n    \u003cbody\u003e\n    \u003c/body\u003e\n    \u003c/html\u003e\n    ```\n\n    b. Then add `wagtail_non_admin_draftail/draftail_media.html` to the `wagtail_non_admin_draftail_head` block on every page that uses the editor.\n\n    For example, if you have a page template called `post_edit.html` that renders a form with the editor, add the following block to that template:\n    ```django\n    {% block wagtail_non_admin_draftail_head %}\n      {% include \"wagtail_non_admin_draftail/draftail_media.html\" %}\n      {{ form.media }}  {# Add this line if your template doesn't use \"{{ form }}\" but renders fields individually #}\n    {% endblock wagtail_non_admin_draftail_head %}\n    ```\n    That's it! The Draftail editor should now have all the JS/CSS required to boot up on the page.\n\n5. Use `NonAdminDraftailRichTextArea` as the widget for your form field to enable Draftail on non-admin pages:\n    ```python\n    from wagtail_non_admin_draftail.widgets import NonAdminDraftailRichTextArea\n\n    class NoteForm(forms.ModelForm):\n        class Meta:\n            model = Note\n            fields = [\"text\"]\n            widgets = {\"text\": NonAdminDraftailRichTextArea}\n    ```\n\n# Configuration\n\nBy default, all images and documents uploaded via Non-admin Draftail are saved in Wagtail's Images/Documents library, in the \"Public uploads\" collection. You can customize the name of the collection by defining the `WAGTAIL_NON_ADMIN_DRAFTAIL_PUBLIC_COLLECTION_NAME` variable in your main Django `settings.py` file:\n\n```\nWAGTAIL_NON_ADMIN_DRAFTAIL_PUBLIC_COLLECTION_NAME = \"Visitor uploads\"\n```\n\n# Usage\nAssuming the following steps:\n\n1. You have a model that has a Wagtail `RichTextField`:\n    ```python\n    from django.db import models\n    from wagtail.fields import RichTextField\n\n    class JobPost(models.Model):\n      title = models.CharField(max_length=255)\n      body = RichTextField()\n    ```\n\n2. Ensure that `job_post_form.html` (or whatever template is responsible for rendering the Job post edit form) includes `draftail_media.html` in the `\u003chead\u003e` of the page (see step 4 of the Installation instructions above).\n\n3. Now, when you visit a page with a `JobPostForm` form, you should see the body field with the Draftail editor enabled.\n\n# Contributing\n\n## How to run the example project locally\nTo contribute, you may want to run the local project. Here is how to do it:\n\n1. This project uses [Poetry](https://python-poetry.org/) for packaging and dependency management (if you have Poetry installed, skip this step):\n    ```\n    pip install poetry\n    ```\n\n2. Clone the repo:\n    ```\n    git clone https://github.com/timonweb/wagtail-non-admin-draftail.git\n    ```\n\n3. Change into the cloned directory:\n    ```\n    cd wagtail-non-admin-draftail\n    ```\n\n4. Install dependencies with Poetry:\n    ```\n    poetry install\n    ```\n\n5. Run the project with Poetry:\n    ```\n    poetry run python manage.py runserver\n    ```\n\n6. Open your browser and go to the test form page: [http://127.0.0.1:8000/example/form/](http://127.0.0.1:8000/example/form/)\n\n## How to run the test suite\nAssuming you have completed steps 1–4 above, you can run the `pytest` test suite with the following command:\n```\npoetry run pytest\n```\n\nIf tests fail and the installation is fresh, make sure that Playwright (the end-to-end test library used) is installed. Run the following command to install it:\n\n```\npoetry run python -m playwright install chromium\n```\n\n# Created by\n[Tim Kamanin - A Full Stack Python / JavaScript Developer](https://timonweb.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimonweb%2Fwagtail-non-admin-draftail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimonweb%2Fwagtail-non-admin-draftail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimonweb%2Fwagtail-non-admin-draftail/lists"}