Ask Your Question

Introduce Custom Tags

asked 2014-01-12 09:01:07 -0600

SocialQA's avatar

updated 2014-01-12 09:01:56 -0600

I see the templatetags folder inside askbot. I have been adding all the new apps that I build on top of askbot under askbot folder.

I have my main application askbot and inside that I have experiments folder as another application.

I used askbot's utils module to introduce the tags of my application. I used the

def set_experiment_user(view_func):
    '''Decorator for setting the WebUser for use with ab split testing assumes
    first argument is the request object'''
    def decorator(request, *args, **kwargs):
        return view_func(request, *args, **kwargs)
    return decorator

Then in my view

def ask_widget(request, widget_id):

and in the template, I have done the following:

{% import "macros.html" as macros %}

{% load experiments %}
{% experiment experiment_name top_contributors %}
{% if contributors and settings.SIDEBAR_MAIN_SHOW_AVATARS %}
    {% include "widgets/contributors.html" %}
{% endif %}
{% endexperiments %}

But I get the following error: But I get the following error:

Encountered unknown tag 'experiment'.
Request Method: GET
Request URL:    http://localhost:8001/questions/
Django Version:  1.4.10
Exception Type:  TemplateSyntaxError
Exception Value:    
Encountered unknown tag 'experiment'.
Exception Location: ../askbot/templates/main_page/sidebar.html in template, line 4

this means that it doesn't understand the "experiment" template tag, I read the following url since I have 'django.core.context_processors.request', in I didn't think i have to do anything to make sure custom templates to be registered.

It would be a great help if you could provide any insight on this.

I also have in my experiment module should I be my set_experiment into that instead of askbot's utils.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-01-12 11:08:15 -0600

Evgeny's avatar

We are using Jinja2 templates, therefore please refer to their documentation. Also, in Jinja2 it's easier to write custom template filters rather than template tags, perhaps you could achieve your goal that way.

edit flag offensive delete link more


but if I want to do this was it should work right? I don't want to deal with Jinja as want to avoid as much as possible.

SocialQA's avatar SocialQA  ( 2014-01-12 14:50:22 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-01-12 09:01:07 -0600

Seen: 230 times

Last updated: Jan 12 '14