A simple Django app to add comment and related operations to your models.
Project description
## Django Comment
``django-comment`` is a simple Django app to add comments for your django model.
This project is inspired by [django-taggit](https://github.com/alex/django-taggit) and directly derived from [django-vote](https://github.com/shanbay/django-vote)
[![Build Status](https://travis-ci.org/shanbay/django-comment.svg)](https://travis-ci.org/shanbay/django-comment)
[![Codecov](https://codecov.io/gh/shanbay/django-comment/coverage.svg?branch=master)](https://codecov.io/gh/shanbay/django-comment?branch=master)
[![PyPI version](https://badge.fury.io/py/django-comment.svg)](https://badge.fury.io/py/django-comment)
### Quick start
#### Add `'comment'` to your `INSTALLED_APPS` setting like this
```python
INSTALLED_APPS = (
...
'comment',
)
```
#### Add `CommentModel` to the model you want to comment
```python
from comment.models import CommentModel
class ArticleReview(CommentModel):
...
```
#### Run migrate
```shell
manage.py makemigrations
manage.py migrate
```
#### Use comment API
```python
review = ArticleReview.objects.get(pk=1)
# Add comment for an object
review.comments.create(user_id, content)
# Removes a comment from the object
review.comments.get(pk=comment_id).delete()
# Check if the user commented the object
review.comments.filter(user_id=user_id).exists()
# Returns the number of comments for the object
review.comments.count()
# Returns all comments by user
review.comments.filter(user_id=user_id)
# Use comment_objects like a native manager
Review.comment_objects.filter(user_id=user_id).limit(10)
```
``django-comment`` is a simple Django app to add comments for your django model.
This project is inspired by [django-taggit](https://github.com/alex/django-taggit) and directly derived from [django-vote](https://github.com/shanbay/django-vote)
[![Build Status](https://travis-ci.org/shanbay/django-comment.svg)](https://travis-ci.org/shanbay/django-comment)
[![Codecov](https://codecov.io/gh/shanbay/django-comment/coverage.svg?branch=master)](https://codecov.io/gh/shanbay/django-comment?branch=master)
[![PyPI version](https://badge.fury.io/py/django-comment.svg)](https://badge.fury.io/py/django-comment)
### Quick start
#### Add `'comment'` to your `INSTALLED_APPS` setting like this
```python
INSTALLED_APPS = (
...
'comment',
)
```
#### Add `CommentModel` to the model you want to comment
```python
from comment.models import CommentModel
class ArticleReview(CommentModel):
...
```
#### Run migrate
```shell
manage.py makemigrations
manage.py migrate
```
#### Use comment API
```python
review = ArticleReview.objects.get(pk=1)
# Add comment for an object
review.comments.create(user_id, content)
# Removes a comment from the object
review.comments.get(pk=comment_id).delete()
# Check if the user commented the object
review.comments.filter(user_id=user_id).exists()
# Returns the number of comments for the object
review.comments.count()
# Returns all comments by user
review.comments.filter(user_id=user_id)
# Use comment_objects like a native manager
Review.comment_objects.filter(user_id=user_id).limit(10)
```
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-comment-1.0.2.tar.gz
(4.9 kB
view hashes)
Built Distribution
Close
Hashes for django_comment-1.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab390c6ebda870419a46c5a034952dc6f68fbe6c972a8c49c9d7a789c291d10d |
|
MD5 | 97f9a66a4b5ee7e7e952b70e64b1eb4f |
|
BLAKE2b-256 | 05bfed5cff5913716a836b9e49e0a64707617c373227f616c77da7f2cd9cf127 |