django 添加comments app
django 添加comments app
安装和配置comments
1.安装comments,运行:pip install django-contrib-comments
命令
2.settings.py中做如下操作:
- INSTALLED_APPS下添加
'django.contrib.sites'
- INSTALLED_APPS下添加
'django_comments'
- 定义SITE_ID ,
SITE_ID = 1
3.令comments app生效
django-admin migrate
4.配置url
- 修改url.py添加comment app url
urlpatterns = [
...
url(r'^comments/', include('django_comments.urls')),
...
]
5.生成comments表
python manage.py migrate
(blog) [root@localhost blog]# python manage.py migrate
Operations to perform:
Apply all migrations: admin, django_comments, blogpost, sessions, sites, auth, contenttypes
Running migrations:
Rendering model states... DONE
Applying sites.0001_initial... OK
Applying django_comments.0001_initial... OK
Applying django_comments.0002_update_user_email_field_length... OK
Applying django_comments.0003_add_submit_date_index... OK
Applying sites.0002_alter_domain_unique... OK
扫描公众号,关注更多信息
---------------------------------------------------------------------------------我是分割线--------------------------------------------------------------------------to be a better me, talk is cheap show me the code
版权所有,转载请注明原文链接。
文中有不妥或者错误的地方还望指出,以免误人子弟。如果觉得本文对你有所帮助不妨【推荐】一下!如果你有更好的建议,可以给我留言讨论,共同进步!
再次感谢您耐心的读完本篇文章。
----------------------------------------------------------------------------------------------------------------------------------------------------------------------