diff --git a/django/contrib/comments/__init__.py b/django/contrib/comments/__init__.py
index 42384e7..4d32af0 100644
a
|
b
|
|
1 | 1 | from django.conf import settings |
2 | 2 | from django.core import urlresolvers |
3 | 3 | from django.core.exceptions import ImproperlyConfigured |
4 | | from django.contrib.comments.models import Comment |
5 | | from django.contrib.comments.forms import CommentForm |
6 | 4 | from django.utils.importlib import import_module |
7 | 5 | |
8 | 6 | DEFAULT_COMMENTS_APP = 'django.contrib.comments' |
… |
… |
def get_model():
|
40 | 38 | if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_model"): |
41 | 39 | return get_comment_app().get_model() |
42 | 40 | else: |
| 41 | from django.contrib.comments.models import Comment |
43 | 42 | return Comment |
44 | 43 | |
45 | 44 | def get_form(): |
… |
… |
def get_form():
|
49 | 48 | if get_comment_app_name() != DEFAULT_COMMENTS_APP and hasattr(get_comment_app(), "get_form"): |
50 | 49 | return get_comment_app().get_form() |
51 | 50 | else: |
| 51 | from django.contrib.comments.forms import CommentForm |
52 | 52 | return CommentForm |
53 | 53 | |
54 | 54 | def get_form_target(): |
diff --git a/django/contrib/comments/models.py b/django/contrib/comments/models.py
index 5e128d2..2c5dff4 100644
a
|
b
|
from django.db import models
|
8 | 8 | from django.core import urlresolvers |
9 | 9 | from django.utils.translation import ugettext_lazy as _ |
10 | 10 | from django.conf import settings |
| 11 | from django.contrib.comments import get_model |
11 | 12 | |
12 | 13 | COMMENT_MAX_LENGTH = getattr(settings,'COMMENT_MAX_LENGTH',3000) |
13 | 14 | |
… |
… |
class CommentFlag(models.Model):
|
166 | 167 | if you want rating look elsewhere. |
167 | 168 | """ |
168 | 169 | user = models.ForeignKey(User, verbose_name=_('user'), related_name="comment_flags") |
169 | | comment = models.ForeignKey(Comment, verbose_name=_('comment'), related_name="flags") |
| 170 | comment = models.ForeignKey(get_model(), verbose_name=_('comment'), related_name="flags") |
170 | 171 | flag = models.CharField(_('flag'), max_length=30, db_index=True) |
171 | 172 | flag_date = models.DateTimeField(_('date'), default=None) |
172 | 173 | |
diff --git a/tests/regressiontests/comment_tests/tests/app_api_tests.py b/tests/regressiontests/comment_tests/tests/app_api_tests.py
index c4d9ebf..9e94634 100644
a
|
b
|
|
1 | 1 | from django.conf import settings |
2 | 2 | from django.contrib import comments |
3 | | from django.contrib.comments.models import Comment |
| 3 | from django.contrib.comments.models import Comment, CommentFlag |
4 | 4 | from django.contrib.comments.forms import CommentForm |
5 | 5 | from regressiontests.comment_tests.tests import CommentTestCase |
6 | 6 | |
… |
… |
class CommentAppAPITests(CommentTestCase):
|
28 | 28 | c = Comment(id=12345) |
29 | 29 | self.assertEqual(comments.get_approve_url(c), "/approve/12345/") |
30 | 30 | |
| 31 | def testCommentFlagCommentModel(self): |
| 32 | self.assertEqual(CommentFlag.comment.field.related.parent_model, Comment) |
| 33 | |
31 | 34 | |
32 | 35 | class CustomCommentTest(CommentTestCase): |
33 | 36 | urls = 'regressiontests.comment_tests.urls' |
… |
… |
class CustomCommentTest(CommentTestCase):
|
69 | 72 | def getGetApproveURL(self): |
70 | 73 | c = Comment(id=12345) |
71 | 74 | self.assertEqual(comments.get_approve_url(c), "/approve/12345/") |
| 75 | |
| 76 | def testCommentFlagCommentModel(self): |
| 77 | from regressiontests.comment_tests.custom_comments.models import CustomComment |
| 78 | self.assertEqual(CommentFlag.comment.field.related.parent_model, CustomComment) |
| 79 | |