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

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


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)

Uploaded Source

File details

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

File metadata

  • Download URL: django-social-layer-0.0.8.tar.gz
  • Upload date:
  • Size: 30.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.3

File hashes

Hashes for django-social-layer-0.0.8.tar.gz
Algorithm Hash digest
SHA256 6ce0c074b5fcbacd1b38a2296eb6bcab727ef0eb09d81df95c8c173979e3c8d0
MD5 bbd4d7d12c6b42cec7ab64d5be115e98
BLAKE2b-256 fb901d06d03095a3439f3e56fc05b4289a5bda0aacb2f05c87faea29355a7407

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