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]
### Quick start
#### Add `'vote'` to your `INSTALLED_APPS` setting like this
```python
INSTALLED_APPS = (
...
'comment',
)
```
#### Add `VoteModel` to the model you want to vote
```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)
```
``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]
### Quick start
#### Add `'vote'` to your `INSTALLED_APPS` setting like this
```python
INSTALLED_APPS = (
...
'comment',
)
```
#### Add `VoteModel` to the model you want to vote
```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)
```
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.0.tar.gz
(6.3 kB
view hashes)
Built Distribution
Close
Hashes for django_comment-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f87d130ee6625228cf561f1bd234a5b6ce1a92c8afef7625db89fe502e73490 |
|
MD5 | c063ef8771490f20db9b101b121f2372 |
|
BLAKE2b-256 | b248748b152d75086aab35ae47b0881f585c869a3f3f711889c8afe942ad999d |