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)
[](https://travis-ci.org/shanbay/django-comment)
[](https://codecov.io/gh/shanbay/django-comment?branch=master)
[](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)
# Override auto_time and auto_time_add in model fields
from comment.utils import override_autotime
with override_autotime():
com = review.comments.create(user_id, content, created_at=your_timestamp)
print(com.created_at) # your timestamp
```
``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)
[](https://travis-ci.org/shanbay/django-comment)
[](https://codecov.io/gh/shanbay/django-comment?branch=master)
[](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)
# Override auto_time and auto_time_add in model fields
from comment.utils import override_autotime
with override_autotime():
com = review.comments.create(user_id, content, created_at=your_timestamp)
print(com.created_at) # your timestamp
```
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.3.tar.gz
(5.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-comment-1.0.3.tar.gz.
File metadata
- Download URL: django-comment-1.0.3.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
834b1688a132ccb76be70a800ba28d0491fb07d37e2ab863ce34d607d4822e4b
|
|
| MD5 |
ca93337ae0178fce75c6503179728c90
|
|
| BLAKE2b-256 |
30bbee549d0dc71d4adde54c179a702cfb7b60bdfaf61d3d330fa0f85a31ff49
|
File details
Details for the file django_comment-1.0.3-py2.py3-none-any.whl.
File metadata
- Download URL: django_comment-1.0.3-py2.py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3c8aa3647ba354b9f721e9bf1eeb811403e47821f736b5a197fda4746c540df
|
|
| MD5 |
467ba915b412bddb5fd0b8756681d0e8
|
|
| BLAKE2b-256 |
a73399cefdd8c6091a8e85ef85129f2108b52113dae27df00c63b7aed39d07c0
|