I'm having trouble finding out how to change the settings in the django-taggit-templatetags
package without actually going in and modifying the source code. I followed the README instructions here: https://github.com/feuervogel/django-taggit-templatetags
I basically did a pip install into my virtualenv, so the package is saved under venv/lib/python3.4/site-packages
.
I wanted to change the default weight settings for the tagcloud's tags. The instructions say:
There are a few settings to be set:
TAGGIT_TAGCLOUD_MIN (default: 1.0) This specifies the minimum of the weight attribute of a tagcloud's tags.
TAGGIT_TAGCLOUD_MAX (default: 6.0) This specifies the maximum of the weight attribute of a tagcloud's tags.
If you want to use the weight as font-sizes, just do as follows:
<font size={{tag.weight|floatformat:0}}>{{tag}}</font>
So the weights are converted to integer values.
In the code, in taggit_templatetags/templatetags/taggit_extras.py
, I see:
T_MAX = getattr(settings, 'TAGCLOUD_MAX', 6.0)
T_MIN = getattr(settings, 'TAGCLOUD_MIN', 1.0)
Is there any way I can access this through Django and change the settings? I'm having trouble plugging into the black box of Django and figuring out what is and is not possible. I thought of asking on the 'Issues' board, but the project looks kind of dead right now. I figured this was a general third-party installation question, so hoping to find someone here. Thank you for any help.
In your settings.py
add two new properties
#This specifies the minimum of the weight attribute of a tagcloud's tags.
TAGGIT_TAGCLOUD_MIN = <yourvalue>
#This specifies the maximum of the weight attribute of a tagcloud's tags.
TAGGIT_TAGCLOUD_MAX = <yourvalue>
The code you mentioned:
T_MAX = getattr(settings, 'TAGCLOUD_MAX', 6.0)
T_MIN = getattr(settings, 'TAGCLOUD_MIN', 1.0)
tries to get that values from settings, and if not found falls back to defaults (6.0 and 1.0)