Installation & Configuration
Install using pip
python -m pip install django-comment-systemor Clone the repository and copy comment folder and paste in project folder.
git clone https://github.com/mahyar-amiri/django-comment-system.gitAdd 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', ] # your account login url LOGIN_URL = 'admin:login' # or reverse_lazy('admin:login') MEDIA_URL = '/media/' MEDIA_ROOT = BASE_DIR / 'media'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')), ] urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)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' %}
Release files for django-comment-system 2.10.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-comment-system-2.10.4.tar.gz | 957.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_comment_system-2.10.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.9 MB
Release files / django-comment-system-2.10.4.tar.gz
| Download URL | django-comment-system-2.10.4.tar.gz |
|---|---|
| Size | 957.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8621e1c3e481379f157254c9a0080f8d1d80ea2b0272a5794c611bb290b961d1
|
|
BLAKE2b-256 checksum How to use checksums |
6940cf2f578ac237b074ce0bbe89b9c0ae507272c4433c59459424846888ff17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.3
|
Release files / django_comment_system-2.10.4-py3-none-any.whl
| Download URL | django_comment_system-2.10.4-py3-none-any.whl |
|---|---|
| Size | 969.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
34c0e3ed2d52d50604a8b55b93ac8c1f2e3e1a777dc2a2010d99c79e37720d78
|
|
BLAKE2b-256 checksum How to use checksums |
5c5a1955f2854a05461c537613438d0b9b5e8e1885b944040aa255de61d9e67a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.3
|