django-knowledge makes it easy to add an integrated support desk, help desk or knowledge base to your Django project with only a few lines of boilerplate code. While we give you a generic design for free, you should just as easily be able to customize the look and feel of the app if you like.
django-knowledge was developed internally for Zapier. Check out a live demo.
Django Knowledge is aiming to be a very simple knowledge base and question support engine, not entirely dissimilar to ZenKnowledge, Assistly, or HelpJuice, and to some degree StackOverflow or even UserVoice or GetSatisfaction.
The goals of django-knowledge are simple and straightforward:
At its core, there are only a few moving parts, which keeps django-knowledge light and extensible.
There are only three data models in django-knowledge: Question, Response and Category. As you can imagine, Question is the base model which can have an arbitrary number or Response‘s. While Response is more or less a series of comments on a Question. Question‘s can also have an arbitrary number of Categories.
Question‘s and Response‘s can each be either public, private or internal (or inheret for Response). Categories are always public.
In the same spirit, there are only 4 user facing views: knowledge_index, knowledge_list, knowledge_thread, and knowledge_ask.
- Using pip or easy_install, which is most common for stable releases.
- Using a Git checkout, recommended if you want cutting-edge features.
- Using downloadable archives, useful if you don’t have pip or git.
We highly recommend using pip to install django-knowledge, the packages are regularly updated with stable releases:
pip install django-knowledge
Or, alternatively:
easy_install django-knowledge
But really, you shouldn’t do that.
Regular development happens at our GitHub repository. Grabbing the cutting edge version might give you some extra features or fix some newly discovered bugs. We recommend not installing from the git repo unless you are actively developing django-knowledge. Please don’t use it in production (and if you do, report back what broked)!
git clone git@github.com:zapier/django-knowledge.git django-knowledge
You can add the knowledge folder inside the resulting django-knowledge to your PYTHONPATH or simply run python setup.py install to add it to your site-packages.
Visit our tags page to grab the archives of both current and previous stable releases. After unzipping or untarring, you can add the knowledge folder inside the resulting django-knowledge to your PYTHONPATH or simply run python setup.py install to add it to your site-packages.
First, you’ll want to add knowledge and django.contrib.markup to your INSTALLED_APPS. You may need to pip install markdown to cover the markup dependency.
INSTALLED_APPS = (
'django.contrib.contenttypes',
'django.contrib.comments',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
# Your favorite apps
'django.contrib.markup',
'knowledge',)
Second, add url(r'^knowledge/', include('knowledge.urls')) to your urls.py.
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
# your url patterns
url(r'^knowledge/', include('knowledge.urls')),
)
Third, be sure to run python manage.py syncdb or python manage.py migrate knowledge to set up the necessary database tables.
python manage.py syncdb
# or...
python manage.py migrate knowledge
Finally, follow the steps outlined in the Customize section for templates and static resources. Short version, don’t forget to run python manage.py collectstatic.
python manage.py collectstatic
Right now django-knowledge is still under heavy development. We’re approaching the full development of this product in the manner described below.
Documentation first!
This is vitally important as we pusposefully want to create something that is a best in class application. We want django-knowledge be the premier help desk for django.
Tests next!
Again, we want people to trust this application, so tests are an absolute must. TDD is the name of the game here. 100% coverage is the goal.
Code final!
And let’s make it good code as well. pep8 and all that jazz!
Please join us in making django-knowledge the best open source help desk in the world!
We’re using Sphinx, so make sure you have pip install sphinx, browse on into the docs folder and run make html:
cd docs
make html
Inside docs/_build should be the rendered html. Open up docs/_build/html/index.html in your browser to take a looksy.
Editing the files is equally simple, just adhere to the reStructuredText format. I recommend using something like watch while doing documentation to auto build everything while you work:
cd docs
watch make html
Inside the tests directory is a bash script that runs a localized Django project that tests our application in a project context. A quick command should suffice for most basic needs:
tests/runtests.sh
Right now we’re not bundling tests inside the installed package, they are part of their own example application. All tests are found in tests/example/tests/ under split out files reflecting their location in the package.
View the coverage stats by opening up the resulting tests/reports/index.html.
Setting up the development server is quite easy as well:
pip install -r requirements.txt
tests/syncdb.sh
tests/runserver.sh
We do use SASS (and you should too!), so you will need to follow their install docs and then run something like:
sass --watch knowledge/static/knowledge/scss:knowledge/static/knowledge/css
Please remember to run pep8 and fix any errors you see, or explan why you won’t in your commit message so we can yell at you:
pep8 knowledge
We work off of the master branch in our GitHub repo. Send a pull request! Tagged releases will be pushed to PyPi.
django-knowledge has built in functionality that sends email alerts to subscribed users when a new response is added or accepted. Users can opt-in or out this alert at the time of posting a question or response.
Further, Users with the flag ‘is_staff’ and the permission to change questions will receive updates when a new question is added.
TODO: They can also opt-in or out after the fact.
By default, alerts are disabled. to enable them, simply add to your settings.py:
KNOWLEDGE_ALERTS = True
Also ensure that the Django site framework is installed and setup properly, otherwise the default links may not work properly.
SITE_ID = 1
INSTALLED_APPS = (
# ...
'django.contrib.sites',
# ...
)
By default, django-knowledge will greedily send emails via whatever email backend you have set during the request/response cycle. This is likely not desirable: we recommend using something like django-celery-email to delay the task via a queue. No further action is needed if you go this route.
Alternatively, you can specify your own email function where you can introduce your own off request functionality:
KNOWLEDGE_ALERTS_FUNCTION_PATH = 'path.to.your.own.function'
The email function should expect three keyword arguments:
Take a look at knowledge.signals.send_alerts for the original alert function to get an idea how it works.
Note: just to clarify: if you change the email function path setting, you will need to send the alert emails (or any other form of communication) yourself. Our builtin function will no longer act.
We offer three default templates used to render both the subject and message of alert emails:
Emails are sent with both txt and html formats. Simply override these if you want to modify the defaults.
Since django-knowledge ships with default themes and styles, you might have to spend a little time perfecting your look. However, it should work right out of the box with minimal setup (or none!) if you don’t mind the defaults.
The default base template is django_knowledge/base.html which contains a single {% block knowledge_inner %} tag. This base template loads two css files from your static (see below): reset.css and base.css.
If you do decide to change the base template via the KNOWLEDGE_BASE_TEMPLATE setting, your new template might look something like this:
<!doctype html>
<html lang="en">
<head>
<title>{% block title %}{% endblock title %} | Johnny's Support Center</title>
<link rel="stylesheet" href="{{ STATIC_URL }}css/my-own-reset.css">
<link rel="stylesheet" href="{{ STATIC_URL }}css/my-own-style.css">
<!-- don't forget to add me! -->
<link rel="stylesheet" href="{{ STATIC_URL }}knowledge/css/main.css">
</head>
<body>
<div class="wrapper">
<div class="header">
Welcome to the Johnny's app!
</div>
<div class="content">
{% block knowledge_inner %}
{% block content %}
<!-- your tradition content is loaded here if not django knowledge -->
{% endblock content %}
<!-- django knowlege is loaded here -->
{% endblock knowledge_inner %}
</div>
<div class="footer">
Copyright 2012
</div>
</div>
</body>
</html>
That isn’t to say that our css styles will fit in perfectly, but we’ve been careful to namespace under dk-` the majority of our css classes, so conflicts should be minimal.
1. Ensure static resources are loading for {{ STATIC_URL }}knowledge/css/reset.css and {{ STATIC_URL }}knowledge/css/main.css. 2. Done.
There are two very common areas for modification:
As long as you are using Django’s static files system, setting up static files should be as easy as python manage.py collectstatic. If not, you can always copy your files manually to a legacy MEDIA_URL and override the base template according to the above templates section.
Likewise, feel free to override the included CSS with your own rules in your own stylesheets. We’d recommend not editing the included CSS, as an update or collectstatic might overwrite them.
We purposefully namespace the majority of our CSS classes with dk- in order to keep them from conflicting with your existing CSS. There are two included CSS files:
A few of the queries in the manager are a little crazy due to the need to check parent questions when responses are inherited status. We recommend ensuring the following indexes for the following fields:
If you decide to turn on email alerts, we highly recommend using something like django-celery-email or creating your own function for delayed execution with Celery, gevent, or whatever.
Django Knowledge has its own series of custom settings you can use to tweak its operation. As with normal Django settings, these go in settings.py, or a variant thereof.
Default False. If True, users who are not logged in can ask questions. If False only registered and logged in users can ask questions.
Default False. If True users that are not authenticated are redirected to LOGIN_URL.
Default False. If True, answered questions are automatically published. If False, staff must manually publish questions after answering.
Default True. If True, any user (respecting KNOWLEDGE_ALLOW_ANONYMOUS) can respond to any question. If False, only staff or original poster may respond.
Default True. If True, the URL for a question will have the slug from its title appended to the end and incorrect or missing slugs will result in a 301 redirect. If False, the slug is ommitted.