Skip to main content

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',
    '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.
    comment_section, n  = CommentSection.objects.get_or_create(url=request.path)
    context = {'commentsection': comment_section}
    return render(request, 'my_view.html', context)

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.

Metadata

Release files for django-social-layer 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-social-layer 1.0.2
File Size Uploaded
django-social-layer-1.0.2.tar.gz 89.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-social-layer 1.0.2
File Interpreter ABI Platform
django_social_layer-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 227.1 kB

Release files / django-social-layer-1.0.2.tar.gz

Download URL django-social-layer-1.0.2.tar.gz
Size 89.8 kB
Tags Source
SHA-256 checksum
How to use checksums
db7245a720425ad2b7065ce9d313aea0894fe13034ffe625fa2fa19f957285d4
BLAKE2b-256 checksum
How to use checksums
d38cf9d7b752d6890398b78dd7deb4751b350cd3ddea664fe4729801420c71c3
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / django_social_layer-1.0.2-py3-none-any.whl

Download URL django_social_layer-1.0.2-py3-none-any.whl
Size 137.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7535f2025243e7a105a8ea96cf896f8de15bea8988bf0193ef97073c2385d10d
BLAKE2b-256 checksum
How to use checksums
1436a22f3acf37622a0716bb0a8b69cce6d3b4796a3821baab24406b43bd342c
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

1 release file

0.3.5

1 release file

0.3.4

1 release file

0.3.3

1 release file

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.8

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.0.9

1 release file

0.0.8

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page