Registry /
web-framework / django-contrib-comments
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
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 68.5MB
glibcpy 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.fixInstall `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.fixAdd `'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.fixAfter adding `'django_comments'` to `INSTALLED_APPS`, run `python manage.py migrate`.
affects: All versions
gotchaDisplaying comments in templates requires specific template tags and context.fixIn 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.