Skip to content
This repository was archived by the owner on Jan 15, 2019. It is now read-only.

Docs refer to non-existant KNOWLEDGE_BASE_TEMPLATE setting #42

Open
sbisker opened this issue Mar 6, 2013 · 11 comments
Open

Docs refer to non-existant KNOWLEDGE_BASE_TEMPLATE setting #42

sbisker opened this issue Mar 6, 2013 · 11 comments

Comments

@sbisker
Copy link

sbisker commented Mar 6, 2013

We've been customizing the style of django-knowledge and were looking forward to using the KNOWLEDGE_BASE_TEMPLATE setting to avoid having to drop a custom build of all of django-knowledge into our source base. However, the KNOWLEDGE_BASE_TEMPLATE setting seems to be absent from the source.
Is this a setting that is in development, and the docs are too new? Or is this a depreciated setting and the docs need to be scrubbed? Thanks.

@Gabrinthei
Copy link

I was also curious about this. The docs say that you just need to copy and modify the base.html into your own template folder.. but that isn't any good if the app is just using the default ones.
@sbisker, did you happen to find a solution to this without dropping a custom build into your base?

@robnewman
Copy link

I am also having this issue. This setting does exist, but doesn't seem to work. Look at the settings file line 18:

BASE_TEMPLATE = getattr(settings, 'KNOWLEDGE_BASE_TEMPLATE', 'django_knowledge/base.html')

However, it doesn't seem to have any effect when you make the change in your local settings.py.

Here is a simple test, using Django's built in shell command from your projects root directory:

% python manage.py shell
>>> from knowledge.settings import *
>>> print LOGIN_REQUIRED
False
>>> print LOGIN_URL
/path/to/my/local/custom/auth/login
>>> print BASE_TEMPLATE
Traceback (most recent call last):
  File "<console>", line 1, in <module>
NameError: name 'BASE_TEMPLATE' is not defined

As you can see, all of the others work, except BASE_TEMPLATE.

@robnewman
Copy link

Okay, I have found the issue. I assume both of you installed from pip just like I did? Well, here is the contents of knowledge/settings.py as installed by pip:

from django.conf import settings

# crowd control
LOGIN_REQUIRED = getattr(settings, 'KNOWLEDGE_LOGIN_REQUIRED', False)
LOGIN_URL = getattr(settings, 'LOGIN_URL', '/accounts/login/')
ALLOW_ANONYMOUS = getattr(settings, 'KNOWLEDGE_ALLOW_ANONYMOUS', False)
AUTO_PUBLICIZE = getattr(settings, 'KNOWLEDGE_AUTO_PUBLICIZE', False)
FREE_RESPONSE = getattr(settings, 'KNOWLEDGE_FREE_RESPONSE', True)

# alerts
ALERTS = getattr(settings, 'KNOWLEDGE_ALERTS', False)
ALERTS_FUNCTION_PATH = getattr(settings, 'KNOWLEDGE_ALERTS_FUNCTION_PATH',
    'knowledge.signals.send_alerts')

# misc
SLUG_URLS = getattr(settings, 'KNOWLEDGE_SLUG_URLS', True)

Notice something missing? Yup. No

BASE_TEMPLATE = getattr(settings, 'KNOWLEDGE_BASE_TEMPLATE', 'django_knowledge/base.html')

It looks like even though the author recommends using the stable release via pip, that DOES NOT have the custom template. Sloppy. You might like to clone the Git repo instead. That's what I am going to do. Good luck.

@robnewman
Copy link

After updating from Github directly:

pip install -e git+https://github.com/zapier/django-knowledge.git#egg=django-knowledge

This now works:

% python manage.py shell
>>> from django.conf import settings
>>> from knowledge.settings import *
>>> print BASE_TEMPLATE
django_knowledge/base.html

Like I said before... sloppy.

@bryanhelmig
Copy link
Member

We haven't pushed the recent updates to PyPi yet.

@robnewman
Copy link

Then (with respect as you are providing this for free, and thank you) you should really make a note of this on the readthedocs page at a minimum. Its pretty much a deal breaker for me, and probably other devs, if they can't apply their own chrome/skin to the app.

@bryanhelmig
Copy link
Member

Valid point, we definitely should. I'd be happy to accept a pull request that addresses some of this, as I can't devote time to cleaning up django-knowledge in the near short-term... 😦

@robnewman
Copy link

That is also a valid point (that you can't devote time), and I am aware that open-source sometimes means extra 'features'. If I get time I will try and address some of this issues. Regards.

@robnewman
Copy link

One final comment on this. This project also assumes that your custom templates live in the global space under: mysite/mysite/templates/, as shown in the current Django docs.

For large Django projects the standard is to create per application template directories. So, if you have installed django-knowledge and want to have your own templates, you need to either put your custom knowledge templates under mysite/mysite/templates/django_knowledge, or hack your settings.py file to point to your own custom app templates.

I did the latter as I have a very large Django project, and to make it work with my custom templates I had to create my own app knowledge with it's own templates directory. To make it work via my settings.py here is what I did:

if 'knowledge' in INSTALLED_APPS:
    # Ugly hack. If we install django-knowledge via pip it is
    # installed under site_packages, and the templates therein are used.
    # However, we want to override this with our own templates, but not in
    # the projects global templates directory due to keeping a clean house.
    # So need to define a path that Django's built in
    # Template Loaders can find. Use relative paths.
    TEMPLATE_DIRS += (PROJECT_PATH + '/../knowledge/templates',)
    KNOWLEDGE_BASE_TEMPLATE = 'django_knowledge/base.html'

This is ugly, but it works.

@bryanhelmig
Copy link
Member

Thanks for the feedback and insight, I definitely appreciate it! Hopefully I'll get a rainy afternoon sometime and give our open source stuff some love and attention. 😄

@sbisker
Copy link
Author

sbisker commented Sep 30, 2013

Sorry, was traveling in Japan, so very late to this. :) Agreed that this fix needs to make its way upstream, but we wound up simply cloning the repo for now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants