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
New: users now can post content, images, videos, etc.
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.apps.SocialLayerConfig',
'infscroll', # required
]
# the login url to redirect site visitors to a social account.
# Note that you need to take care of auth and user registration.
SOCIAL_VISITOR_LOGIN = '/login/'
run migrations:
./manage.py migrate
USAGE
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 optionally can have an owner.
from social_layer.comments.models import CommentSection
comment_section = CommentSection.objects.create(url=request.path)
Now inside a view, lets add a commennt section for the page:
from social_layer.comments.models import CommentSection
def my_view(request):
# in this example, we'll use the url to match the page.
cmt_section, n = CommentSection.objects.get_or_create(url=request.path)
return render(request, 'my_view.html',
{'comment_section': cmt_section})
To finish, add this to the template:
{% load static %}
<script defer application="javascript" src="{% static 'social_layer/js/social_layer.js' %}"></script>
<link rel="stylesheet" href="{% static 'social_layer/css/social_layer.css' %}"/>
...
<p>The comment section will render below.</p>
{% include 'social_layer/comments/comment_section.html' %}
Get and create a SocialProfile for an authenticated user:
from social_layer.utils import get_social_profile
def my_view(request):
profile = get_social_profile(request)
Hope this can be useful to you.
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
Built Distribution
Hashes for django-social-layer-0.2.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c142f2ff2ce97cd621d858eca0c2bf2a0761667085ac79fd6d06de662a7ae67a |
|
MD5 | 1308a6c79d2aece9b942d24b36d3523f |
|
BLAKE2b-256 | a6718331810d45a1f837db1bda0f4ca2757359860f4e87154cb64cf572cf60fa |
Hashes for django_social_layer-0.2.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04b72b0ae8805d53f6810a03d32e456caf6dc528040087982c07e0b10795f61d |
|
MD5 | 76bf221ff353b13dc950a86c11eee1c1 |
|
BLAKE2b-256 | de84517d86d374b20a84bf1d2bc289c4dfbe23a66ce98476da347f67938d549d |