Django Comment System, It can be associated with any given model.
Project description
Installation & Configuration
Install using pip
python -m pip install django-comment-system
or Clone the repository and copy comment folder and paste in project folder.
git clone https://github.com/mahyar-amiri/django-comment-system.git
Add comment.apps.CommentConfig to installed_apps in the settings.py file after django.contrib.auth.
# setting.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # MY APPS 'comment.apps.CommentConfig', ]
Add path('comment/', include('comment.urls')), to urlpatterns in the urls.py file.
# urls.py from django.urls import path, include urlpatterns = [ path('comment/', include('comment.urls')), ]
Connect comments to target model. In models.py add the field comments as a GenericRelation field to the required model.
NOTE: Please note that the field name must be comments NOT comment.
# models.py from django.db import models from django.contrib.contenttypes.fields import GenericRelation from comment.models import Comment class Article(models.Model): title = models.CharField(max_length=20) content = models.TextField() # the field name should be comments comments = GenericRelation(Comment)
Do migrations
python manage.py migrate
Usage
In the template (e.g. post_detail.html) add the following template tags where obj is the instance of post model.
{% load comment_tags %}
Add the following template tags where you want to render comments.
{% render_comments request obj settings_slug='default-config' %} {# Render all the comments belong to the passed object "obj" #}
if your context_object_name is not obj (e.g article) replace obj with context_object_name.
{% render_comments request obj=article settings_slug='default-config' %}
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-comment-system-2.7.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04c096276eca5b80cae4ba52f06fd0183ce3d002b59d9d60f387e23fa9a032ae |
|
MD5 | 1505e473b6127640e84fab0e5567f1f7 |
|
BLAKE2b-256 | 3d728e538f2408335c65ac51ef0186bfbf8d0da8cd8c8a78dfbc3f225e56a4c3 |
Hashes for django_comment_system-2.7.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a11a558f413a3c25760e6d4fafa88a31c6bcd36e85134495e6b5155b18bec5d |
|
MD5 | b2aaaa07c091572c2d37af45e98625d9 |
|
BLAKE2b-256 | 4b107291f4b19c51bf3a173ff47f98efb90c8bdd4c1cc4044be3ea4fdde305da |