Django Comment app. It can be associated with any given model.
Project description
django-comments-dab
Thanks https://www.pythonanywhere.com/
Here is a live demo
Full Documentation
Content:
Introduction
dab stands for Django-Ajax-Bootstrap PS: Ajax and JQuery are not used anymore since v2.0.0 Vanilla JS and fetch API is used instead.
django-comments-dab is a commenting application for Django-powered websites.
It allows you to integrate commenting functionality with any model you have e.g. blogs, pictures, video etc…
List of actions that can be performed:
Post a new comment. (v2.0.0 authenticated and anonymous users)
Reply to an existing comment. (v2.0.0 authenticated and anonymous users)
Edit a comment. (authenticated user comment owner)
Delete a comment. (authenticated user comment owner and admins)
React to a comment. (authenticated users) Available reactions are LIKE and DISLIKE # open PR if you would like to have more reactions
Report (flag) a comment. (authenticated users)
Delete flagged comment. (admins and moderators)
Resolve or reject flag. This is used to revoke the flagged comment state (admins and moderators)
Follow and unfollow thread. (authenticated users)
All actions are done by Fetch API since V2.0.0
Bootstrap 4.1.1 is used in comment templates for responsive design.
Installation
Requirements:
django>=2.1
djangorestframework # only for the API Framework
Bootstrap 4.1.1
Installation:
Installation is available via pip
$ pip install django-comments-dab
or via source on github
$ git clone https://github.com/radi85/Comment.git $ cd Comment $ python setup.py install
Migrations:
Migrate comment app:
$ python manage.py migrate comment
Setup
Step 1 - Connecting comment model with the target model
In models.py add the field comments as a GenericRelation field to the required model.
PS: Please note that the field name must be comments NOT comment.
E.g. Post model, as shown below:
from django.contrib.contenttypes.fields import GenericRelation
from comment.models import Comment
class Post(models.Model):
author = models.ForeignKey(User)
title = models.CharField(max_length=200)
body = models.TextField()
# the field name should be comments
comments = GenericRelation(Comment)
Usage
1. Basics usage:
include_bootstrap tag is for bootstrap-4.1.1, if it’s already used in the project, get rid of this tag.
In the template (e.g. post_detail.) add the following template tags where obj is the instance of post model.
{% load comment_tags %} {# Loading the template tag #}
{% render_comments obj request %} {# Render all the comments belong to the passed object "obj" #}
{% include_bootstrap %} {# Include bootstrap 4.1.1 - remove this line if BS is already used in your project #}
2. Advanced usage:
For advanced usage and other documentation, you may read the Documentation or look at the docs directory in the repository.
Example
You can play with the example app using local virtual environment
$ git clone https://github.com/Radi85/Comment.git # or clone your forked repo
$ cd Comment
$ python3 -m venv local_env # or any name. local_env is in .gitignore
$ export DEBUG=True
$ source local_env/bin/activate
$ pip install -r test/example/requirements.txt
$ python manage.py migrate
$ python manage.py create_initial_data
$ python manage.py runserver
Or run with docker
$ git clone https://github.com/Radi85/Comment.git # or clone your forked repo
$ cd Comment
$ docker-compose up
Login with:
username: test
password: test
The icons are picked from Feather. Many thanks to them for the good work.
Email’s HTML template is used from https://github.com/leemunroe/responsive-html-email-template
Contributing
For contributing, please see the instructions at Contributing
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
File details
Details for the file django-comments-dab-2.8.0.tar.gz
.
File metadata
- Download URL: django-comments-dab-2.8.0.tar.gz
- Upload date:
- Size: 113.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e151fa84847294a9e7c754dc4600ae7edfd28b72fc9e6ba5329eb20b851ef60e |
|
MD5 | 468e2aea80764f5123a2875acdd39c00 |
|
BLAKE2b-256 | 82cc8e5b41d63ed441b56e7078eaf219f8e79dde57494e89be58900544ee1a9a |
File details
Details for the file django_comments_dab-2.8.0-py3-none-any.whl
.
File metadata
- Download URL: django_comments_dab-2.8.0-py3-none-any.whl
- Upload date:
- Size: 163.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e781d4d295d09b8422486c4dccfbeb8f741b1f0f1e32ceb20a3875ea23c33d1f |
|
MD5 | d895a992548ebd2610277e6f0596ce14 |
|
BLAKE2b-256 | 8e700843375a7a8bae9ebb1b91c8d915c9ac77fab37455f0745e2a5462659bc3 |
Comment Settings and urls:
settings.py should look like this:
In urls.py: