diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 5403d81..6061c97 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -24,6 +24,7 @@ jobs:
run: echo "RELEASE_VERSION=0.0.1" >> $GITHUB_ENV
- name: Install Dependencies
run: |
+ pip install django-tinymce
pip install Django
pip install -e .
- name: Run Tests
diff --git a/README.md b/README.md
index a8fdd58..97808e7 100644
--- a/README.md
+++ b/README.md
@@ -56,6 +56,7 @@ add any or all to change to desired behavior::
11. no_question_votes - add if only want answer voting
12. allow_unicode - add if you want to allow unicode slugs
13. login_required - add if you want to only let logged in users see FAQ's
+14. rich_text_answers - add if you want to use rich text for answers. This requires the django-tinymce package to be installed
## Templates
@@ -317,6 +318,24 @@ the app name for the urls is ``'faq'``
* only works if using question voting
* used to post hidden input vote = 1 or vote = 0 depending on vote up or down
+## django-tinymce
+If you want to use rich text answers you will need to [install django-tinymce](https://django-tinymce.readthedocs.io/en/latest/installation.html#id2)
+
+Make sure to include in the template the `{{ form.media }}` to include the tinymce javascript and css files.
+> [!WARNING]
+> Failing to follow the following steps will result in a xss vulnerability in your site.
+
+To allow the rich text answers to be rendered properly you will need to use the safe filter in your templates.
+While django-tinymce does escape the html the answers that were created when the rich text editor was not enabled **has not been escaped and is not safe**.
+So these answers cannot be rendered with the safe filter. So a flag was added to the answer model 'is_rich_text' that is set to True when the answer is created with the rich text editor.
+In the template you can use the following code to render the answer properly::
+
+ {% if answer.is_rich_text %}
+ {{answer.answer|safe}}
+ {% else %}
+ {{answer.answer}}
+ {% endif %}
+
## Contributing
django-easy-faq aims to be the best faq app for django. It welcomes contributions of all types - issues, bugs, feature requests, documentation updates, tests and pull requests
@@ -340,4 +359,6 @@ django-easy-faq aims to be the best faq app for django. It welcomes contributio
1.6 fixed bug where no_category_description did not do remove the category description in the admin
-1.7 added support for django 5.0
\ No newline at end of file
+1.7 added support for django 5.0
+
+1.8 added support for richtext answers with django-tinymce
\ No newline at end of file
diff --git a/example/example/settings.py b/example/example/settings.py
index a96e9ef..9b251f9 100644
--- a/example/example/settings.py
+++ b/example/example/settings.py
@@ -35,7 +35,8 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
- 'faq'
+ 'faq',
+ 'tinymce',
]
MIDDLEWARE = [
@@ -150,4 +151,9 @@
# https://github.com/smark-1/django-easy-faq
# Django easy FAQ settings
-FAQ_SETTINGS = []
\ No newline at end of file
+FAQ_SETTINGS = [
+ 'logged_in_users_can_answer_question',
+ 'allow_multiple_answers',
+ 'rich_text_answers',
+ 'logged_in_users_can_add_question',
+]
\ No newline at end of file
diff --git a/example/example/urls.py b/example/example/urls.py
index ccc90e6..938a049 100644
--- a/example/example/urls.py
+++ b/example/example/urls.py
@@ -6,5 +6,6 @@
path("", home),
path('faq/', include('faq.urls')),
path("admin/", admin.site.urls),
+ path('tinymce/', include('tinymce.urls')),
]
diff --git a/example/templates/faq/answer_form.html b/example/templates/faq/answer_form.html
index 23a2b35..0e3a7fd 100644
--- a/example/templates/faq/answer_form.html
+++ b/example/templates/faq/answer_form.html
@@ -16,20 +16,22 @@
{% endblock %}
{% block content %}
+ {{ form.media }}
{{question.question}}
{{ answer.answer|safe }}
+ {% else %}