Package: django-comments-dab
django-comments-dabThankshttps://www.pythonanywhere.com/Here is alivedemoFullDocumentationContent:IntroductionInstallationSetupUsageExampleIntroductiondab stands for Django-Ajax-BootstrapPS: Ajax and JQuery are not used anymore since v2.0.0 Vanilla JS and fetch API is used instead.django-comments-dabis a commenting application for Django-powered websites.It allows you to integrate commenting functionality with any model you have e.g. blogs, pictures, video etc…List of actions that can be performed:Post a new comment. (v2.0.0 authenticated and anonymous users)Reply to an existing comment. (v2.0.0 authenticated and anonymous users)Edit a comment. (authenticated usercomment owner)Delete a comment. (authenticated usercomment ownerand admins)React to a comment. (authenticated users) Available reactions are LIKE and DISLIKE  # open PR if you would like to have more reactionsReport (flag) a comment. (authenticated users)Delete flagged comment. (admins and moderators)Resolve or reject flag. This is used to revoke the flagged comment state (admins and moderators)Follow and unfollow thread. (authenticated users)All actions are done by Fetch API since V2.0.0Bootstrap 4.1.1 is used in comment templates for responsive design.InstallationRequirements:django>=2.1djangorestframework# only for the API FrameworkBootstrap 4.1.1Installation:Installation is available viapip$ pip install django-comments-dabor via source on github$ git clone https://github.com/radi85/Comment.git
$ cd Comment
$ python setup.py installComment Settings and urls:Addcommentto installed_apps in thesettings.pyfile. It should be added afterdjango.contrib.auth.LOGIN_URLshall be defined in the settings.settings.pyshould look like this:INSTALLED_APPS=('django.contrib.admin','django.contrib.auth',...'comment',..)LOGIN_URL='login'# or actual urlInurls.py:urlpatterns=patterns(path('admin/',admin.site.urls),path('comment/',include('comment.urls')),...path('api/',include('comment.api.urls')),# only required for API Framework...)Migrations:Migrate comment app:$ python manage.py migrate commentSetupStep 1 - Connecting comment model with the target modelIn models.py add the fieldcommentsas aGenericRelationfield to the required model.PS: Please note that the field name must becommentsNOTcomment.E.g.Postmodel, as shown below:fromdjango.contrib.contenttypes.fieldsimportGenericRelationfromcomment.modelsimportCommentclassPost(models.Model):author=models.ForeignKey(User)title=models.CharField(max_length=200)body=models.TextField()# the field name should be commentscomments=GenericRelation(Comment)Step 2 - Adding template tags:render_commentstag uses 2 required and 1 optional args:Instance of the targeted model. (Required)Request object. (Required)oauth. (optional - Default is false)Usage1. Basics usage:include_bootstraptag is for bootstrap-4.1.1, if it’s already used in the project, get rid of this tag.In the template (e.g. post_detail.) add the following template tags whereobjis the instance of post model.{%loadcomment_tags%}{# Loading the template tag #}{%render_commentsobjrequest%}{# Render all the comments belong to the passed object "obj" #}{%include_bootstrap%}{# Include bootstrap 4.1.1 - remove this line if BS is already used in your project #}2. Advanced usage:For advanced usage and other documentation, you may read theDocumentationor look at thedocsdirectory in the repository.ExampleYou can play with the example app using local virtual environment$gitclonehttps://github.com/Radi85/Comment.git# or clone your forked repo$cdComment$python3-mvenvlocal_env# or any name. local_env is in .gitignore$exportDEBUG=True$sourcelocal_env/bin/activate$pipinstall-rtest/example/requirements.txt$pythonmanage.pymigrate$pythonmanage.pycreate_initial_data$pythonmanage.pyrunserverOr run with docker$gitclonehttps://github.com/Radi85/Comment.git# or clone your forked repo$cdComment$docker-composeupLogin with:username:testpassword:testThe icons are picked fromFeather. Many thanks to them for the good work.Email’s HTML template is used fromhttps://github.com/leemunroe/responsive-html-email-templateContributingFor contributing, please see the instructions atContributing