Skip to main content

Adds social media features to any website

Project description

DJANGO SOCIAL LAYER

django-social-layer - Adds social media features to any website.

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


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.2.5.tar.gz (80.6 kB view details)

Uploaded Source

Built Distribution

django_social_layer-0.2.5-py3-none-any.whl (120.9 kB view details)

Uploaded Python 3

File details

Details for the file django-social-layer-0.2.5.tar.gz.

File metadata

  • Download URL: django-social-layer-0.2.5.tar.gz
  • Upload date:
  • Size: 80.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for django-social-layer-0.2.5.tar.gz
Algorithm Hash digest
SHA256 9454bd8f2f3b7df6a59ff4e319594d2b72231d7fd8d3dcbbd0ab7ba7e8e3d363
MD5 f57ed00974f149d6c2ac09f5e9ab7422
BLAKE2b-256 f01868cf29912fc56daa4a96f1d13165a926900c6ca8dbad176c44690416671c

See more details on using hashes here.

File details

Details for the file django_social_layer-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: django_social_layer-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 120.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for django_social_layer-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 97fb9d6bd5922aa64f610a3e38e00f797085b6dcf2397493e94683bbf9d8583c
MD5 070970a0cec9106747a571da6adea7b6
BLAKE2b-256 3a5235d0643e79796cf7e43d440fc4fe8c2168fb052d6aba2501aeb3a49a872f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page