Adds social media features to any website
Project description
FEATURES
easly add a comment section to any webpage
users can like comments
notifications
users have profile page
INSTALATION
Install django-social-layer:
pip install django-social-layer
Add to urls.py:
path('', include(('social_layer.urls', 'social_layer'), namespace="social_layer"))
add to settings.py:
INSTALLED_APPS = [
...
'social_layer',
]
run migrations:
./manage.py migrate social_layer
USAGE
Create a SocialProfile for an user:
bob = User.objects.create(username="bob")
social_bob = SocialProfile.objects.create(user=bob)
Create a CommentSection for any purpose. It can, for example, be linked to an object with a ForeignKey field, or to a view by it’s URL. In our example we will use an url, but it’s optional. A CommentSection must have an owner.
comment_section = CommentSection.objects.create(owner=social_bob,
url=request.path)
Now inside a view, lets add a commennt section for the page owned by bob:
def some_awesome_view(request):
social_bob = SocialProfile.objects.get(nick='bob')
# in our example, we use the url to match the page.
comment_section = CommentSection.objects.get(url=request.path)
data = {'comment_section': comment_section}
return render(request, 'awesome_template.html', data)
To finish, add this to the template:
<script defer application="javascript" src="{{ STATIC_ROOT }}social_layer/js/social_layer.js"></script>
<link rel="stylesheet" href="{{ STATIC_ROOT }}social_layer/css/social_layer.css"/>
<p>A comment section will render below.</p>
{% include 'comments/comment_section.html' %}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-social-layer-0.0.8.tar.gz
(30.9 kB
view details)