Skip to content

Commit 19d8dee

Browse files
author
Sam Cooke
committed
Finalising for merge
1 parent 014b24f commit 19d8dee

File tree

11 files changed

+45
-24
lines changed

11 files changed

+45
-24
lines changed

README.rst

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
Django-Experiments
22
==================
33

4-
Django-Experiments is an AB Testing Framework for Django and Nexus. It is
5-
completely usable via template tags.
4+
Django-Experiments is an AB Testing Framework for Django.
65

7-
If you don't know what AB testing is, check out `wikipedia <http://en.wikipedia.org/wiki/A/B_testing>`_.
8-
9-
.. image:: https://s3-eu-west-1.amazonaws.com/mixcloud-public/django-experiments/Screen+Shot+2014-09-03+at+2.20.32+PM.png
6+
It is possible to set up an experiment through template tags only.
7+
Through the Django admin you can monitor and control experiment progress.
108

11-
.. image:: https://s3-eu-west-1.amazonaws.com/mixcloud-public/django-experiments/Screen+Shot+2014-09-03+at+2.20.47+PM.png
9+
If you don't know what AB testing is, check out `wikipedia <http://en.wikipedia.org/wiki/A/B_testing>`_.
1210

1311
Changelog
1412
---------
13+
1.1.0
14+
~~~~~
15+
16+
- Nexus is no longer required or used - the standard Django admin for the Experiment model takes over the functionality previously provided by Nexus - NOTE this may have some backwards incompatibilities depending on how you included the media files
17+
- Promote an experiment to a particular alternative (other than Control) through the admin
18+
- New experiment_enroll assignment tag (see below)
19+
1520
1.0.0
1621
~~~~~
1722

@@ -81,9 +86,9 @@ pip is still the recommended way to install dependencies:
8186
Dependencies
8287
------------
8388
- `Django <https://github.com/django/django/>`_
84-
- `Nexus <https://github.com/disqus/nexus>`_
8589
- `Redis <http://redis.io/>`_
8690
- `jsonfield <https://github.com/bradjasper/django-jsonfield/>`_
91+
- `django-modeldict <https://github.com/disqus/django-modeldict>`_
8792

8893
(Detailed list in requirements.txt)
8994

@@ -119,8 +124,8 @@ Next, activate the apps by adding them to your INSTALLED_APPS:
119124
#Installed Apps
120125
INSTALLED_APPS = [
121126
...
127+
'django.contrib.admin',
122128
'django.contrib.humanize',
123-
'nexus',
124129
'experiments',
125130
]
126131

@@ -192,6 +197,18 @@ Make sure the experiment tag has access to the request object (not an
192197
issue for regular templates but you might have to manually add it
193198
inside an inclusion tag) or it will silently fail to work.
194199

200+
The experiment_enroll assignment tag can also be used (note that it
201+
takes strings or variables unlike the older experiment tag):
202+
203+
::
204+
205+
{% experiment_enroll "experiment_name" "alternative1" "alternative2" as assigned_alternative %}
206+
{% if assigned_alternative == "alternative1" or assigned_alternative == "alternative2" %}
207+
<a href = "register.html">Please register!</a>
208+
{% else %}
209+
<a href = "register.html">Register now.</a>
210+
{% endif %}
211+
195212
You can also enroll users in experiments and find out what alternative they
196213
are part of from python. To enroll a user in an experiment and show a
197214
different result based on the alternative:
@@ -328,7 +345,7 @@ equal to True.
328345
Managing Experiments
329346
--------------------
330347

331-
Experiments can be managed in the nexus dashboard (/nexus/experiments by
348+
Experiments can be managed in the Django admin (/admin/experiments/experiment/ by
332349
default).
333350

334351
The States
@@ -340,8 +357,8 @@ the control alternative, and no data will be collected.
340357
**Enabled** - The experiment is enabled globally, for all users.
341358

342359

343-
All Settings
344-
------------
360+
Settings
361+
--------
345362

346363
::
347364

example_project/settings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@
132132
'django.contrib.sessions',
133133
'django.contrib.humanize',
134134
'django.contrib.staticfiles',
135-
'nexus',
136135
'experiments',
137136
# Uncomment the next line to enable the admin:
138137
'django.contrib.admin',

example_project/templates/test_page.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{% load experiments %}
2+
{% load staticfiles %}
23
<!DOCTYPE html>
34
<html>
45
<head>
56
<title>Experiment Test Page</title>
67
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script>
7-
<script src="{% url 'nexus:media' 'experiments' 'js/jquery.cookie.js' %}"></script>
8-
<script src="{% url 'nexus:media' 'experiments' 'js/experiments.js' %}"></script>
8+
<script src="{% static "experiments/js/jquery.cookie.js" %}"></script>
9+
<script src="{% static "experiments/js/experiments.js" %}"></script>
910

1011
<script>
12+
{# Standard Django AJAX CSRF support #}
1113
jQuery(document).ajaxSend(function(event, xhr, settings) {
1214
function getCookie(name) {
1315
var cookieValue = null;
@@ -58,6 +60,11 @@
5860
<a href="{% url 'goal' %}">Don't Click Me (test)</a>
5961
{% endexperiment %}
6062

63+
{% experiment_enroll "helloworld" "control" "test" as alternative %}
64+
{% if alternative == "test" %}
65+
You're in the "test" alternative!
66+
{% endif %}
67+
6168
<span onclick="experiments.goal('js_goal')">JS GOAL</span>
6269
<span data-experiments-goal="cookie_goal">COOKIE GOAL</span>
6370

example_project/urls.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22
from django.conf.urls import patterns, include, url
33
from django.views.generic import TemplateView
44

5-
import nexus
6-
75
admin.autodiscover()
8-
nexus.autodiscover()
96

107
urlpatterns = patterns('',
11-
url(r'nexus/', include(nexus.site.urls)),
128
url(r'experiments/', include('experiments.urls')),
9+
url(r'admin/', include(admin.site.urls)),
1310
url(r'^$', TemplateView.as_view(template_name="test_page.html"), name="test_page"),
1411
url(r'^goal/$', TemplateView.as_view(template_name="goal.html"), name="goal"),
1512
)

experiments/admin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ def save_model(self, request, obj, form, change):
7070
class Media:
7171
css = {
7272
"all": (
73-
'experiments/css/admin.css',
73+
'experiments/dashboard/css/admin.css',
7474
),
7575
}
7676
js = (
7777
'https://www.google.com/jsapi', # used for charts
78-
'experiments/js/csrf.js',
79-
'experiments/js/admin.js',
78+
'experiments/dashboard/js/csrf.js',
79+
'experiments/dashboard/js/admin.js',
8080
)
8181

8282
def _admin_view_context(self, extra_context=None):

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def parse_requirements(file_name):
2323

2424
return requirements
2525

26+
2627
def parse_dependency_links(file_name):
2728
dependency_links = []
2829
for line in open(file_name, 'r').read().split('\n'):
@@ -33,16 +34,16 @@ def parse_dependency_links(file_name):
3334

3435

3536
setup(name='django-experiments',
36-
version='1.0.0',
37+
version='1.1.0',
3738
description='Python Django AB Testing Framework',
3839
author='Mixcloud',
3940
author_email='[email protected]',
4041
url='https://github.com/mixcloud/django-experiments',
4142
packages=find_packages(exclude=["example_project"]),
4243
include_package_data=True,
4344
license="MIT license, see LICENSE file",
44-
install_requires = parse_requirements('requirements.txt'),
45-
dependency_links = parse_dependency_links('requirements.txt'),
45+
install_requires=parse_requirements('requirements.txt'),
46+
dependency_links=parse_dependency_links('requirements.txt'),
4647
long_description=open('README.rst').read(),
4748
test_suite="testrunner.runtests",
4849
)

0 commit comments

Comments
 (0)