Giter Site home page Giter Site logo

django-contrib-comments's Introduction

Django "excontrib" Comments

image

image

image

image

Django used to include a comments framework; since Django 1.6 it's been separated to a separate project. This is that project.

This framework can be used to attach comments to any model, so you can use it for comments on blog entries, photos, book chapters, or anything else.

For details, consult the documentation.

django-contrib-comments's People

Contributors

adamchainz avatar alasdairnicol avatar alexriina avatar asieira avatar atodorov avatar ballisticpain avatar bashu avatar cclauss avatar claudep avatar collinanderson avatar crccheck avatar felixxm avatar giginet avatar gmjosack avatar hedleyroos avatar hramezani avatar ivanvenosdel avatar jacobian avatar jaddison avatar jezdez avatar jonas-srb avatar jose-lpa avatar kowito avatar lukaszbanasiak avatar meric avatar minusf avatar pahko avatar pauliuszaleckas avatar subsume-zz avatar timgraham avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-contrib-comments's Issues

Error upgrading from Django 1.7 to 1.8

Getting an error when migrating from Django 1.7 to 1.8 during syncdb:

Applying django_comments.0001_initial...Traceback (most recent call last):
File "manage.py", line 10, in <module>
  execute_from_command_line(sys.argv)
File "/home/ec2-user/.virtualenvs/<redacted>/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
  utility.execute()
File "/home/ec2-user/.virtualenvs/<redacted>/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 346, in execute
  self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/ec2-user/.virtualenvs/<redacted>/local/lib/python2.7/site-packages/django/core/management/base.py", line 394, in run_from_argv
  self.execute(*args, **cmd_options)
File "/home/ec2-user/.virtualenvs/<redacted>/local/lib/python2.7/site-packages/django/core/management/base.py", line 445, in execute
  output = self.handle(*args, **options)
File "/home/ec2-user/.virtualenvs/<redacted>/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 25, in handle
  call_command("migrate", **options)
File "/home/ec2-user/.virtualenvs/<redacted>/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 120, in call_command
  return command.execute(*args, **defaults)
File "/home/ec2-user/.virtualenvs/<redacted>/local/lib/python2.7/site-packages/django/core/management/base.py", line 445, in execute
  output = self.handle(*args, **options)
File "/home/ec2-user/.virtualenvs/<redacted>/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 222, in handle
  executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
File "/home/ec2-user/.virtualenvs/<redacted>/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 110, in migrate
  self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial)
File "/home/ec2-user/.virtualenvs/<redacted>/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 148, in apply_migration
  state = migration.apply(state, schema_editor)
File "/home/ec2-user/.virtualenvs/<redacted>/local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 115, in apply
  operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/home/ec2-user/.virtualenvs/<redacted>/local/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 59, in database_forwards
  schema_editor.create_model(model)
File "/home/ec2-user/.virtualenvs/<redacted>/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 286, in create_model
  self.execute(sql, params or None)
File "/home/ec2-user/.virtualenvs/<redacted>/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 111, in execute
  cursor.execute(sql, params)
File "/home/ec2-user/.virtualenvs/<redacted>/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
  return self.cursor.execute(sql, params)
File "/home/ec2-user/.virtualenvs/<redacted>/local/lib/python2.7/site-packages/django/db/utils.py", line 98, in __exit__
  six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/ec2-user/.virtualenvs/<redacted>/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 62, in execute
  return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "django_comments" already exists

Any idea what might be going wrong here?

"migrate" fails in Django 1.8

Hi guys. I don't know if you're planning to update this package to work with Django 1.8, but this is the current output of migrate with Django 1.8, Python 2.7.6, and Postgres as DB backend:

$ python manage.py syncdb
/home/jerivas/.virtualenvs/comm/local/lib/python2.7/site-packages/django_comments/__init__.py:4: RemovedInDjango19Warning: django.utils.importlib will be removed in Django 1.9.
  from django.utils.importlib import import_module

/home/jerivas/.virtualenvs/comm/local/lib/python2.7/site-packages/django_comments/models.py:2: RemovedInDjango19Warning: django.contrib.contenttypes.generic is deprecated and will be removed in Django 1.9. Its contents have been moved to the fields, forms, and admin submodules of django.contrib.contenttypes.
  from django.contrib.contenttypes import generic

/home/jerivas/.virtualenvs/comm/local/lib/python2.7/site-packages/django_comments/models.py:46: RemovedInDjango19Warning: Model class django_comments.models.Comment doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class Comment(BaseCommentAbstractModel):

/home/jerivas/.virtualenvs/comm/local/lib/python2.7/site-packages/django_comments/models.py:165: RemovedInDjango19Warning: Model class django_comments.models.CommentFlag doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class CommentFlag(models.Model):

/home/jerivas/.virtualenvs/comm/local/lib/python2.7/site-packages/django_comments/forms.py:3: RemovedInDjango19Warning: The django.forms.util module has been renamed. Use django.forms.utils instead.
  from django.forms.util import ErrorDict

/home/jerivas/.virtualenvs/comm/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py:24: RemovedInDjango19Warning: The syncdb command will be removed in Django 1.9
  warnings.warn("The syncdb command will be removed in Django 1.9", RemovedInDjango19Warning)

Operations to perform:
  Synchronize unmigrated apps: staticfiles, messages, django_comments
  Apply all migrations: admin, contenttypes, sites, auth, sessions
Synchronizing apps without migrations:
  Creating tables...
    Creating table django_comments
    Creating table django_comment_flags
    Running deferred SQL...
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/jerivas/.virtualenvs/comm/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/home/jerivas/.virtualenvs/comm/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/jerivas/.virtualenvs/comm/local/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/jerivas/.virtualenvs/comm/local/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/home/jerivas/.virtualenvs/comm/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 25, in handle
    call_command("migrate", **options)
  File "/home/jerivas/.virtualenvs/comm/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 120, in call_command
    return command.execute(*args, **defaults)
  File "/home/jerivas/.virtualenvs/comm/local/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/home/jerivas/.virtualenvs/comm/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 179, in handle
    created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
  File "/home/jerivas/.virtualenvs/comm/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 317, in sync_apps
    cursor.execute(statement)
  File "/home/jerivas/.virtualenvs/comm/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/home/jerivas/.virtualenvs/comm/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/home/jerivas/.virtualenvs/comm/local/lib/python2.7/site-packages/django/db/utils.py", line 97, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/jerivas/.virtualenvs/comm/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "django_content_type" does not exist

Django 1.10 deprecation warning

/home/vagrant/.virtualenvs/localdev/local/lib/python2.7/site-packages/django_comments/urls.py:4: RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got comments.post_comment). Pass the callable instead.
  url(r'^post/$', 'comments.post_comment', name='comments-post-comment'),

/home/vagrant/.virtualenvs/localdev/local/lib/python2.7/site-packages/django_comments/urls.py:5: RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got comments.comment_done). Pass the callable instead.
  url(r'^posted/$', 'comments.comment_done', name='comments-comment-done'),

/home/vagrant/.virtualenvs/localdev/local/lib/python2.7/site-packages/django_comments/urls.py:6: RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got moderation.flag). Pass the callable instead.
  url(r'^flag/(\d+)/$', 'moderation.flag', name='comments-flag'),

/home/vagrant/.virtualenvs/localdev/local/lib/python2.7/site-packages/django_comments/urls.py:7: RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got moderation.flag_done). Pass the callable instead.
  url(r'^flagged/$', 'moderation.flag_done', name='comments-flag-done'),

/home/vagrant/.virtualenvs/localdev/local/lib/python2.7/site-packages/django_comments/urls.py:8: RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got moderation.delete). Pass the callable instead.
  url(r'^delete/(\d+)/$', 'moderation.delete', name='comments-delete'),

/home/vagrant/.virtualenvs/localdev/local/lib/python2.7/site-packages/django_comments/urls.py:9: RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got moderation.delete_done). Pass the callable instead.
  url(r'^deleted/$', 'moderation.delete_done', name='comments-delete-done'),

/home/vagrant/.virtualenvs/localdev/local/lib/python2.7/site-packages/django_comments/urls.py:10: RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got moderation.approve). Pass the callable instead.
  url(r'^approve/(\d+)/$', 'moderation.approve', name='comments-approve'),

/home/vagrant/.virtualenvs/localdev/local/lib/python2.7/site-packages/django_comments/urls.py:11: RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got moderation.approve_done). Pass the callable instead.
  url(r'^approved/$', 'moderation.approve_done', name='comments-approve-done'),

/home/vagrant/.virtualenvs/localdev/local/lib/python2.7/site-packages/django_comments/urls.py:11: RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and will be removed in Django 1.10. Update your urlpatterns to be a list of django.conf.urls.url() instances instead.
  url(r'^approved/$', 'moderation.approve_done', name='comments-approve-done'),

/home/vagrant/.virtualenvs/localdev/local/lib/python2.7/site-packages/django_comments/urls.py:16: RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got django.contrib.contenttypes.views.shortcut). Pass the callable instead.
  name='comments-url-redirect'),

/home/vagrant/.virtualenvs/localdev/local/lib/python2.7/site-packages/django_comments/urls.py:16: RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and will be removed in Django 1.10. Update your urlpatterns to be a list of django.conf.urls.url() instances instead.
  name='comments-url-redirect'),

How can I load the origin templatetags (commets) when I custom comments app.

I follow the doc 'Customizing the comments framework' and build an custom comments app.
The doc teach me set like this:

INSTALLED_APPS = [
    ...
    'my_comment_app',
    ...
]

COMMENTS_APP = 'my_comment_app'

But I want to use the templatetags in origin app. Since 'django_comments' not add in INSTALLED_APPS , I can not load 'templatetags.comments.py' in my template. Must I copy all code from that module to my custom app? Or is there more elegent solution?

Thank for you help!

Could we use PostgreSQL with? "operator does not exist: integer = text" Bug

There's a "bug" in postgreSQL (in fact, it's more a feature: strong typed, contrary to MySQL which is "weakly typed", since PostgreSQL 8.3):

Now if you've got:
models.py

class ArticlesTable(models.Model):
    id = models.IntegerField(primary_key=True) 
    ...

and if you want to display the Articles, whose there's comment, for example, you do:
views.py
latest_comments = ArticlesTable.objects.filter(comments_set__isnull=False)

But PostgreSQL doesn't like that!
error:

ProgrammingError at /

operator does not exist: integer = text
LINE 1: ...ango_comments" ON ( "articles_articlesTable"."id" = "django_...
                                                             ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

How can we avoid this error when using simple filtering?
Hint here: http://stackoverflow.com/questions/16044754/heroku-postgresql-django-comments-tastypie-no-operator-matches-the-given-na

But I don't now how to change that...

Customization doesn't work with Django 1.9

The advice for customizing django_comments apparently won't work with Django 1.9, as the advised method of putting get_model/get_form functions in the init.py file of your comment app will cause a app registry error. I've gotten around this for now like this:

import django_comments
from django_comments.models import Comment
from django_comments.forms import CommentForm

class MyCommentForm(CommentForm):

    def get_comment_model(self):
        return Comment

def my_comments_get_form():
    return MyCommentForm

django_comments.get_form = my_comments_get_form

But obviously that's not a great solution. We'll need some other way of customizing the app.

I keep getting an odd error in my django app

Unhandled exception in thread started by <function check_errors..wrapper at 0x10413e268>
Traceback (most recent call last):
File "/Users/ray/Desktop/myheroku/practice/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(_args, *_kwargs)
(practice) apples-MacBook-Pro:src ray$ ./manage.py runserver
Unhandled exception in thread started by <function check_errors..wrapper at 0x104060488>
Traceback (most recent call last):
File "/Users/ray/Desktop/myheroku/practice/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(_args, *_kwargs)
File "/Users/ray/Desktop/myheroku/practice/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/Users/ray/Desktop/myheroku/practice/lib/python3.5/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
six.reraise(__exception)
File "/Users/ray/Desktop/myheroku/practice/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/Users/ray/Desktop/myheroku/practice/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(_args, **kwargs)
File "/Users/ray/Desktop/myheroku/practice/lib/python3.5/site-packages/django/init.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/ray/Desktop/myheroku/practice/lib/python3.5/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/Users/ray/Desktop/myheroku/practice/lib/python3.5/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/Users/ray/Desktop/myheroku/practice/lib/python3.5/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 673, in _load_unlocked
File "", line 662, in exec_module
File "", line 222, in _call_with_frames_removed
File "/Users/ray/Desktop/myheroku/practice/src/blog/models.py", line 11, in
from dynamic_scraper.models import Scraper, SchedulerRuntime
File "/Users/ray/Desktop/myheroku/practice/lib/python3.5/site-packages/dynamic_scraper/models.py", line 13, in
class ScrapedObjClass(models.Model):
File "/Users/ray/Desktop/myheroku/practice/lib/python3.5/site-packages/django/db/models/base.py", line 102, in new
"INSTALLED_APPS." % (module, name)
RuntimeError: Model class dynamic_scraper.models.ScrapedObjClass doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

whhen I try to use django dynamic scraper

Models did not validate

Possible user error but this would be the right place to track it for other troubleshooters -

I get the following error when attempting to validate my models:

CommandError: One or more models did not validate:
django_comments.comment: Accessor for field 'content_type' clashes with related field 'ContentType.content_type_set_for_comment'. Add a related_name argument to the definition for 'content_type'.
django_comments.comment: Reverse query name for field 'content_type' clashes with related field 'ContentType.content_type_set_for_comment'. Add a related_name argument to the definition for 'content_type'.
django_comments.comment: Accessor for field 'site' clashes with related field 'Site.comment_set'. Add a related_name argument to the definition for 'site'.
django_comments.comment: Accessor for field 'user' clashes with related field 'User.comment_comments'. Add a related_name argument to the definition for 'user'.
django_comments.comment: Reverse query name for field 'user' clashes with related field 'User.comment_comments'. Add a related_name argument to the definition for 'user'.
django_comments.commentflag: Accessor for field 'user' clashes with related field 'User.comment_flags'. Add a related_name argument to the definition for 'user'.
django_comments.commentflag: Reverse query name for field 'user' clashes with related field 'User.comment_flags'. Add a related_name argument to the definition for 'user'.

Deprecations RemovedInDjango18Warning

Hi!

I am using django-contrib-comments with https://github.com/Fantomas42/django-blog-zinnia.

When I try posting the comment, it fails but this may be related to django-zinnia.
Here is the django runserver log I get:

python2.7/site-packages/django_comments/managers.py:19: RemovedInDjango18Warning: BaseManager.get_query_set is deprecated, use get_queryset instead.
qs = self.get_query_set().filter(content_type=ct)

python2.7/site-packages/django_comments/views/comments.py:89: RemovedInDjango18Warning: Options.module_name has been deprecated in favor of model_name
"comments/%s_%s_preview.html" % (model._meta.app_label, model._meta.module_name),

python2.7/site-packages/django_comments/views/comments.py:92: RemovedInDjango18Warning: Options.module_name has been deprecated in favor of model_name
"comments/%s/%s/preview.html" % (model._meta.app_label, model._meta.module_name),

"POST /comments/post/ HTTP/1.1" 200 21711 // Preview

"POST /comments/post/ HTTP/1.1" 500 195984 // Post

I will check if there is something on Zinnia's side.

I am using Python 2.7.6 and Django 1.7.3.

Cheers,
Quentin

"NoReverseMatch at" error

Hi,
When adding the tag {% render_comment_form for prestation %} in my template I catch this error :
Reverse for 'django_comments.views.comments.post_comment' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

Everything is installed (see it with pip freeze and I can import the models in a shell).
My IDE does not find the reference when I add the line " url(r'^comments/', include('django_comments.urls')), " in my urls.py. I don't know if it's linked.

So, do you have any idea ? Thank you.

Converting post_comment to Class Based views

Hi,

I was just wondering if there are any plans to migrate post_comment function to class based views? I am customizing django-contrib-comments to allow for file uploads and will need to copy paste the whole function. Was thinking that it would be much easier if we had the same thing as a class.

Any particular reason why it has not been done yet? Will pull requests for the same be welcome?

Thanks!

Discussion object feature?

Would anyone be interested in a "Discussion object". It would be pluggable like Comments and you could attach things to it. The only thing I can imagine for now would be 'closed' discussions. Otherwise, its kind of awkward because you have to roll this same 'closed' feature into every app that may use comments (blogs, forums, etc)

Django 1.10 deprecation warning (#2)

/home/vagrant/.virtualenvs/localdev/local/lib/python2.7/site-packages/django_comments/__init__.py:73: RemovedInDjango110Warning: Reversing by dotted path is deprecated (django_comments.views.comments.post_comment).
  return urlresolvers.reverse("django_comments.views.comments.post_comment")

CommandError: One or more models did not validate:

(venv)bash-3.2$ ./manage.py sql django_comments
CommandError: One or more models did not validate:
django_comments.comment: Accessor for field 'content_type' clashes with related field 'ContentType.content_type_set_for_comment'. Add a related_name argument to the definition for 'content_type'.
django_comments.comment: Reverse query name for field 'content_type' clashes with related field 'ContentType.content_type_set_for_comment'. Add a related_name argument to the definition for 'content_type'.
django_comments.comment: Accessor for field 'site' clashes with related field 'Site.comment_set'. Add a related_name argument to the definition for 'site'.
django_comments.comment: Accessor for field 'user' clashes with related field 'User.comment_comments'. Add a related_name argument to the definition for 'user'.
django_comments.comment: Reverse query name for field 'user' clashes with related field 'User.comment_comments'. Add a related_name argument to the definition for 'user'.
django_comments.commentflag: Accessor for field 'user' clashes with related field 'User.comment_flags'. Add a related_name argument to the definition for 'user'.
django_comments.commentflag: Reverse query name for field 'user' clashes with related field 'User.comment_flags'. Add a related_name argument to the definition for 'user'.

Any ideas?

No Multiple Database Management

When using several databases (which is allowed by Django : https://docs.djangoproject.com/en/1.7/topics/db/multi-db/) , django-contrib-comments raises an error when trying to post a comment.

Comment post not allowed (400) 
No object matching content-type 'MyModel.mymodeltable' and object PK '1' exists

Problem with the query inside post_comment function where there's no taking into account of multiple databases by a using(database) property?
(as defined in the django docs to make a query with multiple databases:
https://docs.djangoproject.com/en/1.7/topics/db/multi-db/#manually-selecting-a-database )

New release for Django 1.8/1.9 support?

I noticed there are many changes in git which are not released.
Would you be able to make a release for it, so this app can be used for Django 1.9 too?

Thanks in advance!

'Settings' object has no attribute 'COMMENTS_ALLOW_PROFANITIES'

Hi,

I get a crash on django_comments 1.5.1 on my app with the following trace :


Environment:

Request Method: POST
Request URL: http://xxxxxxxx/comments/post/

Django Version: 1.8
Python Version: 2.7.5
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'djangobower',
'django_nvd3',
'django_comments',
'django_bootstrap_breadcrumbs',
'core',
'mailer',
'users',
'projects',
'services',
'qualifications',
'reports')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')

Traceback:
File "/server/CREAM/venv/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response

  1.                 response = wrapped_callback(request, _callback_args, *_callback_kwargs)
    
    File "/server/CREAM/venv/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  2.                 response = view_func(request, _args, *_kwargs)
    
    File "/server/CREAM/venv/lib/python2.7/site-packages/django/views/decorators/http.py" in inner
  3.         return func(request, _args, *_kwargs)
    
    File "/server/CREAM/venv/lib/python2.7/site-packages/django_comments/views/comments.py" in post_comment
  4. if form.security_errors():
    
    File "/server/CREAM/venv/lib/python2.7/site-packages/django_comments/forms.py" in security_errors
  5.         if f in self.errors:
    
    File "/server/CREAM/venv/lib/python2.7/site-packages/django/forms/forms.py" in errors
  6.         self.full_clean()
    
    File "/server/CREAM/venv/lib/python2.7/site-packages/django/forms/forms.py" in full_clean
  7.     self._clean_fields()
    
    File "/server/CREAM/venv/lib/python2.7/site-packages/django/forms/forms.py" in _clean_fields
  8.                 value = getattr(self, 'clean_%s' % name)()
    
    File "/server/CREAM/venv/lib/python2.7/site-packages/django_comments/forms.py" in clean_comment
  9.     if settings.COMMENTS_ALLOW_PROFANITIES == False:
    
    File "/server/CREAM/venv/lib/python2.7/site-packages/django/conf/init.py" in getattr
  10.     return getattr(self._wrapped, name)
    

Exception Type: AttributeError at /comments/post/

Exception Value: 'Settings' object has no attribute 'COMMENTS_ALLOW_PROFANITIES'

I can't understand this error, as this setting does not seem to be handled by django_comments nor django itself...

What could be wrong ?

Multiple Db hits with authenticated users

I've noticed that for each comment of an authenticated user, it will hit the db once to get the user.

We need a select_related('user') to stop this behavior.

I'm not very experienced with Django however, it seems that putting it in the get_queryset method of the BaseCommentNode class will fix the issue.

Can't Migrate

hi, i usng this package. when i install and registered this app in INSTALLED_APP with name 'django_comments' i found this error

django_comments.comment: Accessor for field 'content_type' clashes with related field 'ContentType.content_type_set_for_comment'. Add a related_name argument to the definition for 'content_type'.
django_comments.comment: Reverse query name for field 'content_type' clashes with related field 'ContentType.content_type_set_for_comment'. Add a related_name argument to the definition for 'content_type'.
django_comments.comment: Accessor for field 'site' clashes with related field 'Site.comment_set'. Add a related_name argument to the definition for 'site'.
django_comments.comment: Accessor for field 'user' clashes with related field 'User.comment_comments'. Add a related_name argument to the definition for 'user'.
django_comments.comment: Reverse query name for field 'user' clashes with related field 'User.comment_comments'. Add a related_name argument to the definition for 'user'.
django_comments.commentflag: Accessor for field 'user' clashes with related field 'User.comment_flags'. Add a related_name argument to the definition for 'user'.
django_comments.commentflag: Reverse query name for field 'user' clashes with related field 'User.comment_flags'. Add a related_name argument to the definition for 'user'.

any body can give solution ?

get_comment_list is list, not queryset

When using get_comment_list this line converts the queryset of comments into a Python list. This caused a bug in my threaded-comments code, here's why:

I'm using django-mptt to render threaded comments and their code expects depth-first ordered nodes for their recursetree templatetag. For the nodes to be ordered depth-first, django-mptt checks if the given list of nodes is a queryset and if so, applies the necessary ordering. Since the list is not a queryset and the list is obviously not guaranteed to be in depth-first order, the algorithm fails.

I don't know what consequences it would have to just return a queryset from get_comment_list (they mostly behave the same and it would keep evaluation just a bit more lazy). Furthermore, even though the name says "list", I kinda expected a queryset, simply because that would be more Django-style.

As a workaround I set up my own template tag get_comment_queryset which returns the queryset directly. If changing get_comment_list is a no-go, maybe adding a get_comment_queryset templatetag might be an option. But I guess this issue shall just serve future threaded comment bug hunters as a reference.

Duplicated comments still send the comment_was_posted signal

django_comments return the previews comment if it checked a duplicated comments. This would result in sending the comment_was_posted signal twice. These would get some unexpective results. For example, if I send a notification in comment_was_posted, then user will receive two notifications even there is only one comment. What do you think about this issue? If you think it is nesessary to fix it. I will make a pull requests.

Error when saving comment invalid input syntax for type inet

I'm running python 3.5 and django 1.9.7 on CentOS

Django Version: 1.9.7
Exception Type: DataError
Exception Value:
invalid input syntax for type inet: "b''"
LINE 3: ... '2016-06-28T13:54:40.057911+00:00'::timestamptz, E'b'''''::...

Temporarily, I commented out the auto population of flag_date om the save method of the model

    def save(self, *args, **kwargs):
        #if self.flag_date is None:
         #   self.flag_date = timezone.now()
        pass
        super(CommentFlag, self).save(*args, **kwargs)

and then it worked fine. But of course, flag_date is null.

Need information for 3 strings

Issues reported on Transifex:

forms.py:99

Comment

Is this a noun or a verb?

models.py:179

flag

noun or verb ?
literal translation seldomly used in Dutch.
Need more context to translate correctly.

templates/comments/preview.html:16

or make changes

not translatable, need more context

If you post an answer here, I'll be happy to pass on the information.

Invalid template syntax in django_comments/templates/comments/preview.html

Posting a comment that causes a validation error, such as a comment longer than 300 characters, is supposed to show the django_comments/templates/comments/preview.html template.

From my testing however, I always get an unhandled error from this line.

TemplateSyntaxError at /comments/post/
Invalid block tag: 'comment_form_target', expected 'endblock'

I am using Django 1.8 and Python 2.7

Further step for the porting instructions?

Having just moved over to django-contrib-comments, I was really pleased that the instructions were so simple and it went so smoothly. Well done and thank you!

I had only one fatal error after following those instructions (using Django 1.7.4). I have an app that extends the comments app. The migration for this (there was only the 0001_initial.py migration) was like this:

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations

class Migration(migrations.Migration):

    dependencies = [
        ('comments', '__first__'),
    ]

    operations = [
        migrations.CreateModel(
            name='Annotation',
            fields=[
            ],
            options={
                'proxy': True,
            },
            bases=('comments.comment',),
        ),
    ]

When starting the server I got:

    ...
    File "/Users/phil/.virtualenvs/django-pepysdiary/lib/python2.7/site-packages/django/db/migrations/loader.py", line 169, in check_key
        raise ValueError("Dependency on unknown app: %s" % key[0])
ValueError: Dependency on unknown app: comments`.

Changing the two instances of comments to django_comments in the above migration seems to have fixed the problem (at least, the server runs; I haven't tried any migrations). I'm not sure if that's the best solution, or if it's worth mentioning this kind of thing in the instructions? What would be the best fix if I had a history of migration files that depended on the comments app?

'Options' object has no attribute 'module_name'

I receive an exception from latest django 1.8:
/usr/local/lib/python2.7/dist-packages/django_comments/views/comments.py in post_comment

"comments/%s_%s_preview.html" % (model._meta.app_label, model._meta.module_name),

Missing template files in PyPI package

Hi,

From what I can tell, the PyPI package is missing the templates folder which means that the templates aren't found when using tags like {% render_comment_list for [object] %}.

Maybe I am confused and need another approach but the documentation doesn't seem to mention anything other than:

This will render comments using a template named comments/list.html, a default version of which is included with Django.

Which seems to be true for 1.6 which is confusing as I thought this project exists because contrib.comments is no longer include in Django. Even so the django-contrib-comments docs don't suggest adding django.contrib.comments to INSTALLED_APPS to get access to the templates.

I feel like I must be very confused :) Any help would be much appreciated.

Michael

Source release for version 1.5.1

Hello,

I see on Pypi that the new release of django-contrib-comments (1.5.1) has only be done on the Wheel format.

It's cool for a faster installation, but in my case, my package installer (zc.buildout) does not support Wheel packages.

For a better compatibility, could you make a standard source release ?

Regards

Admin class is sometimes not registered (1.7.2 regression)

Hello,

The following commit e51cbd9 introduced a regression in regards to the admin.

This line:

Klass._meta.app_label is "django_comments"

assumes that both strings share the same memory id, which is true in certain cases (usually inside a REPL):

>>> id("django_comments")
4315523368
>>> id("django_comments")
4315523368
>>> id("django_comments")
4315523368

But when executing this in a script, the ids are different.

So currently Klass._meta.app_label is "django_comments" returns False even though both strings are 'django_comments'.

Django 1.9 support

I'm on my way of upgrading a project that uses django-contrib-comments to Django 1.9. Is Django 1.9 already supported? Thanks in advance

TemplateDoesNotExist

Get's thrown on a fresh pip installed version. (Django 1.5.1/python 2.6/debian)

As a workaround I cloned the template directory in this repo into my own template directory.

Problems overriding templates in custom app with new TEMPLATE setting

During an upgrade to Django 1.8 we ran into some problems overriding the default templates with those in our custom_comments app. It appears the ordering in which django searches through template directories for a template has changed with the introduction of the TEMPLATE setting.

This caused our custom comments to revert to the default templates as they were found by django first. Our templates were at the following path custom_comments/templates/comments/TEMPLATE.html.

We managed to fix this by including our custom_comments app explicitly in the TEMPLATES DIRS list, which bumped our app to the top of the search. Could you please fix how you select templates so custom templates at the following path are override independent of template directory ordering custom_comments/templates/comments/TEMPLATE.html.

Initial manage.py migrate execution

I would like to suggest the documentation on moving from django.contrib.comments to this package include an additional step. I already had data present, so I needed to run python manage.py migrate django_comments --fake-initial or the migration would not happen correctly.

Progress / Roadmap

I'm just curious about the current state and the maintenance of this project as there are issues to which responses are not made. I wish this django app is maintained well.

Custom comment form: AppRegistryNotReady

I suspect this will end up being my fault, but I've been scratching my head for days with no result...

I've upgraded to Django 1.9 from 1.7, and to django-contrib-comments from django.contrib.comments, at the same time (my first mistake). Everything's working well, except that I can't get my custom comment form working. Here's the general layout:

my_comments/forms.py:

from django_comments.forms import CommentForm
from django_comments.models import Comment

class MyCommentForm(CommentForm):
# etc.
    def get_comment_model(self):
        return Comment

and in my_comments/forms.py:

from my_comments.forms import MyCommentForm

def get_form():
    return MyCommentForm

This is giving me an "Apps aren't loaded yet" error. The file my_comments/models.py imports nothing from django_comments but signals. It does import django.contrib.contenttypes, however, which might be relevant to the backtrace:

File "mysite/my_comments/init.py", line 1, in
from my_comments.forms import MyCommentForm
File "mysite/my_comments/forms.py", line 1, in
from django_comments.forms import CommentForm
File "/home/user/dev/pr/src/django-contrib-comments/django_comments/forms.py", line 5, in
from django.contrib.contenttypes.models import ContentType
File "/home/user/dev/pr/lib/python2.7/site-packages/django/contrib/contenttypes/models.py", line 159, in
class ContentType(models.Model):
File "/home/user/dev/pr/lib/python2.7/site-packages/django/db/models/base.py", line 94, in new
app_config = apps.get_containing_app_config(module)
File "/home/user/dev/pr/lib/python2.7/site-packages/django/apps/registry.py", line 239, in get_containing_app_config
self.check_apps_ready()
File "/home/user/dev/pr/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

But I've removed all the contentypes stuff from my_commets/models.py, and get the same error.

There's no reference to the old django.contrib.comments app anywhere in my code.

I can't think of anything else. But this is obviously supposed to work. What else might I be doing wrong?

Thanks,

Hard-coded 2h comment timeout needs to be configurable

A comment form is only valid for about two hours (see here). After that, an empty and confusing 400 response will be returned, killing a probably long and elaborated comment by an innocent commenter.

This timeout definitely needs to be configurable or maybe killed altogether -- having a page open for hours is in my world a legitimate use case.

Add index on submit_date?

Since the default ordering for the model is by submit_date, it seems like submit_date would be a good candidate for db_index=True. A lot of my queries also look for comments after a certain date for which I've been using id instead.

RemovedInDjango18Warning re module_name

I just moved over to django-contrib-comments from django.contrib.comments.

When I post a comment I get this:

/Users/phil/.virtualenvs/django-pepysdiary/lib/python2.7/site-packages/django_comments/views/comments.py:89: RemovedInDjango18Warning: Options.module_name has been deprecated in favor of model_name
  "comments/%s_%s_preview.html" % (model._meta.app_label, model._meta.module_name),

The comment is posted successfully. (Sorry if this is the kind of thing you're well aware of, but I couldn't see it referenced elsewhere.)

CommentFlag incompatible with user-defined comment model

As an example, in models.py:

class SpecialComment(comments.models.BaseCommentAbstractModel):
    # Define fields and stuff here
    pass

If we set this as our model, by overriding get_model and CommentForm.get_comment_model we can create comments fine, but if we try to delete them, we get this error:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python2.7/dist-packages/django/contrib/auth/decorators.py", line 20, in _wrapped_view
    return view_func(request, *args, **kwargs)
  ...
  File "/usr/lib/python2.7/dist-packages/django/contrib/comments/views/moderation.py", line 117, in perform_delete
    flag    = comments.models.CommentFlag.MODERATOR_DELETION
  File "/usr/lib/python2.7/dist-packages/django/db/models/manager.py", line 134, in get_or_create
    return self.get_query_set().get_or_create(**kwargs)
  File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 447, in get_or_create
    obj = self.model(**params)
  File "/usr/lib/python2.7/dist-packages/django/db/models/base.py", line 355, in __init__
    setattr(self, field.name, rel_obj)
  File "/usr/lib/python2.7/dist-packages/django/db/models/fields/related.py", line 366, in __set__
    self.field.name, self.field.rel.to._meta.object_name))
ValueError: Cannot assign "<SpecialComment object>": "CommentFlag.comment" must be a "Comment" instance.

The only way I can think of to avoid this issue is to completely rewrite CommentFlag and the deletion method, thus pretty much reinventing the wheel.

Allow importing base models only

We are only using the base models provided by django-contrib-comments, and hence in order to avoid having our project generate tables/models that won't be used, the app is not included under INSTALLED_APPS.

However this raises a deprecation warning from Django, which is annoying, potentially masks other important issues and we'd like to get rid of. I believe this could be easily addressed if the abstract base classes are put away in a non-models.py module. In fact, this is what django did (see ticket 24564) with the abstract models from django.contrib.auth.

@claudep would you be up to accepting a patch for this and making a release with it? TIA.

No changelog/release

Upgrading django-contrib-comments is hard because there is no changelog, I have to read the git log and guess if anything affects the project

"1 comment was successfully %(action)s." needs placeholder in singular form

My language shares a plural form for 1 and 11, so I have problems translating the following string:

admin.py:78

1 comment was successfully %(action)s.
%(count)s comments were successfully %(action)s.

Please change the singular form to "%(count)s comment was successfully %(action)s."

If I try to use the placeholder, Transifex will block me with "Error: The expression '%(count)s' is not present in the original phrase." so I am unable to translate this string properly.

?next= does not work

It appears from looking at the code that I should be able to do something like:

<A HREF="{% url 'comments-flag' comment.pk %}?next=/someurl">Flag comment</A>

But when I'm on the "Really flag this comment?" page, the hidden 'next' form entry isn't populated.

If (instead of linking) I do a form that POSTs to {% url 'comments-flag' comment.pk %} with my own 'next' field, it does work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.