Skip to content
This repository has been archived by the owner on Feb 17, 2020. It is now read-only.

shanbay/django-comment

Repository files navigation

Django Comment

django-comment is a simple Django app to add comments for your django model.

This project is inspired by django-taggit and directly derived from django-vote

Build Status Codecov PyPI version

Quick start

Add 'comment' to your INSTALLED_APPS setting like this

INSTALLED_APPS = (
  ...
  'comment',
)

Add CommentModel to the model you want to comment

from comment.models import CommentModel

class ArticleReview(CommentModel):
    ...

Run migrate

manage.py makemigrations
manage.py migrate

Use comment API

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages