-
Notifications
You must be signed in to change notification settings - Fork 9
Home
easy-faq is a Django app to allow for a simple yet feature rich faq app. with categories, commenting voting of questions and answers all as an optional part of the app.
-
pip install::
pip install https://github.com/dragoncommits/django-easy-faq/blob/master/dist/django-easy-faq-0.5.tar.gz?raw=true
-
Add "easy-faq" to your INSTALLED_APPS setting like this::
INSTALLED_APPS = [ ... 'faq', ]
-
Include the easy-faq URLconf in your project urls.py like this::
path('faq/', include('faq.urls')),
-
Run
python manage.py makemigrations
to create the faq models migrations. -
Run
python manage.py migrate
to create the faq models. -
Start the development server and visit http://127.0.0.1:8000/admin/ to create a category (you'll need the Admin app enabled).(categories part of the app can be disabled)
-
Visit http://127.0.0.1:8000/faq/ to see the categories.
you can change most things in settings below is a list of all settings add any or all to change to desired behavior::
FAQ_SETTINGS = ['your_settings_here',]
- no_category_description - add if using categories but don't want descriptions for them
- no_category - add if don't want to use categories
- logged_in_users_can_add_question - add if you want any logged in user to be able to ask a question
- logged_in_users_can_answer_question - add if you want any logged in user to be able to answer a question
- allow_multiple_answers - add if you want a question to be able to be answered multiple times
- no_comments - add if don't want to use comments
- anonymous_user_can_comment - add if you want any user to be able to comment including anonymous users
- view_only_comments - add if you want users to see posted comments but not be able to add any more
- no_votes - add if don't want any voting for useful questions or answers
- no_answer_votes - add if only want question voting
- no_question_votes - add if only want answer voting
all of the templates are meant to be overwritten to overwrite them create a faq directory inside of the templates directory and add a html file with the same name to it
if this doesn't work make sure that the templates setting has 'DIRS': ['templates'], in it::
TEMPLATES = [
{
...
'DIRS': ['templates'],
...
},
]
here is a list of templates and there default template you can overwrite
-
categories_list.html - faq main view if using categories::
{% for category in categories %} {% if category.description %}{{category.description}}
{% endif %}
{% endfor %} -
category_detail.html - faq category detail view if using categories::
{% if category.description %}{{category.description}}
{% endif %}
{% for question in category.question_set.all %} {% endfor %}
back {% if can_add_question %} add question {% endif %} -
questions_list.html - lists all questions if not using categories::
{% for question in questions %} {% endfor %}{% if can_add_question %}
add question {% endif %} -
question_detail.html - the question detail page::
{% if can_vote_question %} found this question helpful? {% csrf_token %} yes({{question.helpful}}) {% csrf_token %} no({{question.not_helpful}}) {% endif %} {% if question.category and category_enabled %}category - {{question.category.name}}
{% endif %}
{% if allow_multiple_answers %}
-
{% for answer in question.answer_set.all %}
- {{answer.answer}} {% if can_vote_answer %} | found this answer helpful? {% csrf_token %} yes({{answer.helpful}}) {% csrf_token %} no({{answer.not_helpful}}) {% endif %} {% endfor %}
{% else %} {% if question.answer_set.exists %}
answer:
{% if can_vote_answer %} found this answer helpful? {% csrf_token %} yes({{question.answer_set.first.helpful}}) {% csrf_token %} no({{question.answer_set.first.not_helpful}}) {% endif %} {% else %} no answers yet {% endif %} {% endif %}{% if can_answer_question %} {% if category_enabled %} answer question {% else %} answer question {% endif %} {% endif %}
{% if comments_allowed %}-
{% for comment in question.faqcomment_set.all %}
- posted by {% if comment.user%}{{comment.user}}{% else %}anonymous{% endif %} {{comment.post_time|timesince}} ago {% endfor %}
{% endif %} <fieldset> <legend>Post Your Comment Here:</legend> {% csrf_token %} {{comment_form}} <input type="submit" name="post"> </fieldset> </form> {% endif %}
{% endif %}
-
answer_form.html - form to add answer to question::
{% csrf_token %} {{form}} -
comment_form.html - form to add comments to question (only shows up when form has error because view only gets posted to)::
{% csrf_token %} {{form}} -
question_form.html - form to add a new question::
{% csrf_token %} {{form}} -
vote_form.html - form for voting questions and answers (only shows up when form has error because view only gets posted to)::
{% csrf_token %} {{form}}
-
categories_list.html categories - all the categories (category queryset)
-
categories_detail.html category - the category chosen (category object) can_add_question - bool if the user can add a question (depends on the settings)
-
questions_list.html questions - all the questions (question queryset) can_add_question - bool if the user can add a question (depends on the settings)
-
question_detail.html question - the question chosen (question object) can_vote_question - bool if the user can vote a question (depends on the settings) category_enabled - bool if category enabled in settings allow_multiple_answers - bool if multiple answers allowed in settings can_vote_answer - bool if the user can vote an answer (depends on the settings) can_answer_question - bool if current user can answer question (depends on the settings) comments_allowed - bool if using comments in settings add_new_comment_allowed - bool if current user can add comment (depends on the settings) comment_form - form to submit a new comment
-
answer_form.html question - the question to add answer to (question object) form - form to add new answer
-
comment_form.html question - the question to add comment to (question object) form - form to add new comment
-
question_form.html form - form to add new question
-
vote_form.html form - form to vote for a question or answer
0.4 fixed bug that logged out users can vote - which then raises exceptions 0.5 fixed migrations