I've found a number of incompatibilities with Django 1.5 in django-experiments, nexus, and gargoyle. Fortunately, almost all of them have been fixed by quoting the first parameter to the "url" templatetag everywhere it occurred.

I'm stuck against something I haven't been able to figure out -- I'm getting the following error when I go to my goal page:

NoReverseMatch at /trial/trial1/
Reverse for 'experiment_goal' with arguments '(u'clicktrynow',)' and keyword arguments '{}' not found.

I'm running Django 1.5.1 and Python 2.7.3 on runserver. I can also reproduce this in Python 2.7.4 on Heroku.

My goal page (reaching this page is accomplishing the goal) has this line in it:

{% experiment_goal "clicktrynow" %}

The experiment_goal templatetag appears to automatically include the experiments/goal.html template at this point. experiments/goal.html contains:

<img src="{% url 'experiment_goal' goal_name %}?v={{ random_number }}" height="1" width="1" />

(I've fixed quoting on 'experiment_goal'.)

The urlpatterns for the django-experiments app contains this line:

url(r'^goal/(?P<goal_name>.*)$', 'record_experiment_goal', name="experiment_goal"),

Finally, my settings.py lines relevant to django-experiments are:

EXPERIMENTS_REDIS_HOST = get_env_variable('REDISTOGO_URL', default='redis://localhost:6379')
EXPERIMENTS_REDIS_PORT = 6379
EXPERIMENTS_REDIS_DB = 0
INSTALLED_APPS += ('django.contrib.humanize', 'nexus', 'gargoyle', 'experiments', )
MIDDLEWARE_CLASSES += ('experiments.middleware.ExperimentsMiddleware', )
EXPERIMENTS_GOALS = ('clicktrynow', )

I'm new to Django, but all of this seems like it should work. What am I missing?

Update: My project's urls.py does not include a urls.py from django-experiments. Documentation doesn't say you need to. But perhaps I should. Investigating...

有帮助吗?

解决方案

The django-experiments docs don't mention editing urls.py, but the example project shows you that you need to:

url(r'experiments/', include('experiments.urls')),
url(r'^goal/$', TemplateView.as_view(template_name="goal.html"), name="goal"),
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top