# django-comments-dab Comments
## dab stands for Django-Ajax-Bootstrap
`django-comments-dab` is a commenting application for Django-powered websites.
It allows you to integrate commenting functionality to any model you have eg. blogs, pictures, etc...
List of actions you can do:
#. Add a comment (Authenticated)
#. Edit a comment you posted (Authenticated)
#. Delete a comment you posted (Authenticated)
### All actions are done by ajax - Jquery 3.2.1
### Bootstrap 4.1.1 is used in comment templates for responsive design.
## 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
```
Add `comment` to your installed_apps in your `settings.py` file. It should be added after `django.contrib.auth`:
```python
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
...
'comment',
..
)
```
In your urls.py:
```python
urlpatterns = patterns('',
...
path('comment/', include('comment.urls')),
...
)
```
## Migrations for Django 2.0 and later
Migrate comments:
```
$ python manage.py migrate comment
```
## Setup
### Step 1
In your models.py add the field comments (Please note that field name must be `comments` not `comment`) to the model for which comment should be added (e.g. Post) and the appropriate imports as shown below:
```python
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)
```
### Step 2
`get_comments` tag uses 2 positional and 3 optional args:
#1. The instance of the model. (positional)
#2. User. (positional)
#3. oauth. (optional - Default is false)
#4. profile_app_name. (optional)
#5. profile_model_name. (optional)
`include_static` this tag will include required jquery and javascript file.
`include_bootstrap` for bootstrap 4.1.1 if it's already included in your project, get rid of this tag.
In your template (e.g. post-detail.html) add the following template tags where object is the instance of post.
```python
{% load comment_tags %} # Loading the template tag
{% get_comments object request.user %} # Include all the comments belonging to a certain object
{% include_bootstrap %} # Include bootstrap 4.1.1
{% include_static %} # Include jQuery 3.2.1 and required js file
```
If you have profile model for the user and you would like to show the profile image on each comment you need to pass the profile_app_name and profile_model_name arguments to get_comments tag. (e.g if user profile app is called `accounts` and profile model is called `UserProfile`) the tag will look like the following:
```python
{% load comment_tags %} # Loading the template tag
{% get_comments object request.user profile_app_name='accounts' profile_model_name='userprofile'%} # Include all the comments belonging to a certain object
{% include_bootstrap %} # Include bootstrap 4.1.1
{% include_static %} # Include jQuery 3.2.1 and required js file
```
---
## Styling
If you want to customize your comments style do the following steps:
#. Create a comment.css file inside your static/css directory.
#. The new created file will overwrite the file used in the app.
and you're done.
没有合适的资源?快使用搜索试试~ 我知道了~
PyPI 官网下载 | django-comments-dab-1.0.0.tar.gz
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 4 浏览量
2022-01-10
16:22:08
上传
评论
收藏 63KB GZ 举报
温馨提示
共38个文件
py:14个
html:10个
txt:4个
资源来自pypi官网。 资源全名:django-comments-dab-1.0.0.tar.gz
资源推荐
资源详情
资源评论
收起资源包目录
django-comments-dab-1.0.0.tar.gz (38个子文件)
django-comments-dab-1.0.0
setup.cfg 38B
README.md 3KB
django_comments_dab.egg-info
dependency_links.txt 1B
not-zip-safe 1B
PKG-INFO 896B
SOURCES.txt 1KB
top_level.txt 8B
requires.txt 40B
PKG-INFO 896B
MANIFEST.in 150B
setup.py 1KB
comment
admin.py 305B
models.py 2KB
forms.py 232B
migrations
0002_comment_edit_date.py 381B
__init__.py 0B
0001_initial.py 1KB
static
css
bootstrap-4.1.1.css 155KB
comment.css 1012B
js
jquery-3.2.1.min.js 85KB
comment.js 8KB
templatetags
comment_tags.py 3KB
__init__.py 0B
urls.py 317B
tests.py 60B
__init__.py 0B
apps.py 89B
views.py 4KB
templates
comment
update_comment.html 813B
parent_comment.html 907B
create_comment.html 2KB
child_comment.html 598B
comment_modal.html 807B
commentform.html 833B
update_done.html 1KB
base.html 830B
bootstrap.html 93B
static.html 139B
共 38 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 12w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功