skip to navigation
skip to content

Not Logged In

django-activities 0.0.1

Activites app for django

Latest Version: 1.2.1

NOTE: This is not stable yet and will likely change! Please don't use in production until the 1.0 release.

[<img src="">](
[<img src="">](

django-activities is a generic python activities module written for django. You can create activities about any object type and share that comment with any object type.

Download the source from Github and run::

python django-activities

* [django-generic](
* [django-core](

Config steps:

1. Add to installed apps. django-activities has two dependencies which are listed above. Both need to be added to the installed apps in your settings file.::


By default, django-activities comes with builtin views. You can use them if you like or totally write your own.

To use the views here are a few configuration steps to follow:

1. Create the html file that will be used as the gateway between your application templates and django-activities templates. A simple template would look something like::

# base_activities.html
{% extends request.base_template %}

{% block content %}
{% block activities_content %}{% endblock %}
{% endblock %}

2. Once you're created the base activities html file, you need to link to it in your settings. In your settings file add the following setting that points to your template you just created::

ACTIVITIES_BASE_TEMPLATE = 'path/to/your/template/base_activities.html'

3. Add the context processor in your settings that's used to retrieve your custom base template::


4. Add the urls::

urlpatterns = patterns('',
url(r'^activities', include('activities.urls')),

5. There are also default .less and .js files that will assist the activities as well. These are optional and the js requires jquery. The files are located at::


Form Rendering
Different apps render forms differently. With that in mind, this app lets you define the location for a function in your settings that will be used to render your forms.

For example, if I want to use the [django-bootstrap-form]( app to render forms, I would provide the following setting to the template tag form rendering function::

ACTIVITIES_FORM_RENDERER = 'bootstrapform.templatetags.bootstrap.bootstrap'

Then all forms will render using the django-bootstrap-form library. You can optionally provide the following strings that will render that form using table, paragraph or list tags::

ACTIVITIES_FORM_RENDERER = 'as_p' # render form using <p> tags
ACTIVITIES_FORM_RENDERER = 'as_table' # render form using <table>
ACTIVITIES_FORM_RENDERER = 'as_ul' # render form using <ul>

This will default to rending the form to however the form's ``__str__`` method is defined.

Below are some basic examples on how to use django-activities::

>>> from django.contrib.auth import get_user_model
>>> from activities.models import Activity
>>> User = get_user_model()
>>> user = User.objects.create_user(username='hello')
>>> # The object the activity is about
>>> about_obj = User.objects.create_user(username='world')
>>> n = Activity.objects.create(created_user=user,
... text='Hello world',
... about=about_obj,
... source='COMMENT')
>>> n.text
'Hello world'
>>> user_activities = Activity.objects.get_for_user(user=user)
>>> len(user_activities)
>>> object_activities = Activity.objects.get_for_object(obj=about_obj)
>>> len(object_activities)

Extend the Model
If all this configuration still isn't to your liking, then you can simply extend the Activity model::

# my_activity_app/

from activities.models import AbstractActivity

class MyActivity(AbstractActivity):
"""Your concrete implementation of the activity app."""
# Do your stuff here

Custom Activity Rendering
When rendering the activities, the ``get_html`` will check to see if the activity ``about`` object has implemented custom rendering of the activity itself. In order for the custom rendering to occur, the ``about`` object model needs to implement the class as follows:

def get_activity_created_html(self, activity, **kwargs):
"""The activity renderer for a created activity about this object."""
# do rendering that returns html
return rendered_html

From the ``tests`` directory where the file is, run:

python test  
  • Downloads (All Versions):
  • 13 downloads in the last day
  • 102 downloads in the last week
  • 502 downloads in the last month