Registry / web-framework / django-contrib-comments

django-contrib-comments

JSON →
library2.2.0pypypi✓ verified 89d ago

django-contrib-comments is a standalone Django application providing a robust system for handling user comments. It was extracted from Django core as of version 1.6 and is actively maintained. The current stable version is 2.2.0, with releases typically aligning with major Django versions.

pip install django-contrib-comments
INSTALL
IMPORT
SIG · DJANGO-CONTRIB-COM
D
django-contrib-comments
web-frameworkpythonv2.2.0
Install
3.5s avg
Import
—
Disk
68MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v2.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 68.5MB
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 3.5s · import 0.000s · 69MB
68MB installed
● package 68MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Comment
✓ from django_comments import get_model
✗ from django_comments.models import Comment

Configure your Django project's `settings.py` and `urls.py` to include `django-contrib-comments`. Ensure `django.contrib.sites` is in `INSTALLED_APPS` and `SITE_ID` is set. After setup, run `python manage.py migrate` to create comment-related database tables. Finally, integrate the comment template tags into your desired templates (e.g., using `{% load comments %}`, `{% render_comment_list for object %}`, and `{% get_comment_form for object as form %}`).

import os # --- In your project's settings.py --- INSTALLED_APPS = [ # Required Django core apps 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.sites', # REQUIRED for django-contrib-comments # The comments app itself 'django_comments', # ... your other apps ] SITE_ID = int(os.environ.get('DJANGO_SITE_ID', 1)) # REQUIRED for django-contrib-comments # --- In your project's urls.py --- from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), # Include the comments app's URLs path('comments/', include('django_comments.urls')), # ... your application-specific URLs where comments will be rendered ] # After configuring these, run: python manage.py migrate
Debug
Known issues
breakingThe comments application was removed from Django core (django.contrib.comments) in Django 1.6. Projects upgrading from older Django versions must install and configure `django-contrib-comments` as a standalone package.
fix
Install `django-contrib-comments` via pip, update `INSTALLED_APPS` to `'django_comments'`, and adjust all import paths from `django.contrib.comments` to `django_comments`.
affects: <1.6 (original Django core), >=1.6 (new package)
gotchaThe `django.contrib.sites` framework and the `SITE_ID` setting are mandatory dependencies for `django-contrib-comments` to function correctly.
fix
Add `'django.contrib.sites'` to `INSTALLED_APPS` and define `SITE_ID` (e.g., `SITE_ID = 1`) in your `settings.py`.
affects: All versions
gotchaDatabase tables for comments will not be created without running Django migrations.
fix
After adding `'django_comments'` to `INSTALLED_APPS`, run `python manage.py migrate`.
affects: All versions
gotchaDisplaying comments in templates requires specific template tags and context.
fix
In your template, load the comment tags with `{% load comments %}`. Then use tags like `{% render_comment_list for object %}` and `{% get_comment_form for object as form %}` to display comments and the comment form.
affects: All versions
Upgrade
Version history
2.2.0latest on PyPI · released Jan 31, 2022
Audit
Dependencies
DjangorequiredCore framework dependency, requires Django>=3.2.
Agent activity
7 hits · last 30 days
node
6
Resources
django-contrib-comments — pip install django-contrib-comments · libregistry