I am working on a project where I used a open source framework. Here is the link for the opensource framework: https://github.com/ASKBOT/askbot-devel. I wanted to add a/b testing to it and after doing some research I found out django-lean <https://bitbucket.org/akoha/django-lean/wiki/Home>. I am not an expert in django but I manage to bring the strip down version of the django-lean to my version of askbot-dlevel. I used the blog post<http://alexkehayias.tumblr.com/post/15951774761/ab-split-testing-django>. But my problem is that I am getting following error:
TemplateSyntaxError at /questions/Encountered unknown tag 'experiment'.Request Method: GETRequest URL: http://localhost:8001/questions/Django Version: 1.4.10Exception Type: TemplateSyntaxErrorException Value: Encountered unknown tag 'experiment'. Just to give more information how I incorporate django-lean: As the blog-post mention I only use the experiments module: I added experiments folder from django-lean inside askbot folder and expose it as another install-app using settings file. So now it looks like another application. I copied experiments.py and smartif.py to askbot-dlevel/templatetags because thats the right thing to do based on he django documentation<https://docs.djangoproject.com/en/dev/howto/custom-template-tags/>: also I copied content of the templates folder in the django-lean to askbot-dlevel project's templates folder. So here is how the project looks like: > askbot-dlevel > |__experiments > |__OtherApps > templates > |__experiments > |__other_templates In askbot-dlevel there is a utils folder and in that there is decorators.py, I added the following: def set_experiment_user(view_func): '''Decorator for setting the WebUser for use with ab split testing assumes first argument is the request object''' @functools.wraps(view_func) def decorator(request, *args, **kwargs): WebUser(request).confirm_human() return view_func(request, *args, **kwargs) return decorator This is a slight modification respect to what the blog-post<http://alexkehayias.tumblr.com/post/15951774761/ab-split-testing-django>has mentioned but the logic is still the same. At the point blog-post advise to add it to the views so I added to a view in the askbot-dlevel project: @csrf.csrf_protect@decorators.set_experiment_userdef ask_widget(request, widget_id): def post_question(data, request): thread = models.Thread.objects.create_new(**data) question = thread._question_post() request.session['widget_question_url'] = question.get_absolute_url() return question widget = get_object_or_404(models.AskWidget, id=widget_id) ... after this I added the necessary code to the template file which would add all incoming users to the current experiment that is live on the. Now askbot-dlevel uses jinja2. I but I first tried as the blog post mention because I really don't have a good idea of jinja. So in sidebar.html of the adkbot-dlevel I added 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 %}{% endexperiment %} But that gave me the error that I put at the start of this post. As the blog post mention things should work. Using the admin console I have created an experiment and the name of the experiment is top_contributors. And if things run all users would be in the experiment. But I am getting above mention error which tells me template tags have not been registered. So I tried my best to convert this to jinja format and tried the following: {% if experiments.experiment('top_contributors') %}{% if contributors and settings.SIDEBAR_MAIN_SHOW_AVATARS %} {% include "widgets/contributors.html" %}{% endif %}{% endif %} But that gave me following error: UndefinedError at /questions/'experiments' is undefinedRequest Method: GETRequest URL: http://localhost:8001/questions/Django Version: 1.4.10Exception Type: UndefinedErrorException Value: 'experiments' is undefinedException Location: ..python2.7/site-packages/Jinja2-2.7.1-py2.7.egg/jinja2/environment.py in getattr, line 397Python Executable: ../ABFrameWork/bin/python Hopefully someone can help on solving this problem. Thank You, -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f3b009ea-a66e-4888-83db-8b8bba4e4a9a%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.