Social networking for django. Following system and timeline of events. Heavily inspired by django-sequere The main difference between the projects is that sequeue uses redis while social-timeline uses a database backend. This allows the models to be easily queried but may not have the level of performance a redis backend has. Check out the performance unit tests and consider your own needs.
Status: In development, not suitable for production use.
The concept of one entity following another. We use generic foreign keys to provide high flexibilty here. For example a user would follow another user. We can query who is following a user, or get the list of people a user is following.
Defined as a actor, verb, and target. Actor and target are both generic foreign keys. Target is optional. Examples:
- Jane (actor) joins (verb)
- Joe (actor) comments (verb) on the blog post (our target could be the comment object or the blog post)
social_timeline provides some mixins to make it easy to do common tasks like getting a list of all actions taken by people a user is following.
Installation and usage
Tested on django 1.7, 1.8. Python 3.4.
- Run migrations
- Add FollowMixin to models you with to be capable of following or being followed.
from social_timeline.mixin import FollowMixin class Profile(FollowMixin, models.Model): user = models.OneToOneField('auth.User')
- Review mixin.py for all actions. Examples
user1.follow(user) followering = user1.get_followings() user1.get_timeline()
A starter api is included if you are using django-rest-framework. You may ignore it or extend it for more catered use.
First install docker and docker-compose. You don't need these but it makes it easier.
docker-compose run --rm web ./manage.py migrate
docker-compose run --rm web ./manage.py createsuperuser
docker-compose run --rm web ./manage.py test