Commit 45347d0ae86f7e025197597f41e6d8d078ac8f2d
Committed by
Claude Paroz
1 parent
04b80347
Prevented RemovedInDjango19Warning with get_model
Showing
1 changed file
with
6 additions
and
1 deletions
| @@ -11,6 +11,11 @@ from django.utils.html import escape | @@ -11,6 +11,11 @@ from django.utils.html import escape | ||
| 11 | from django.views.decorators.csrf import csrf_protect | 11 | from django.views.decorators.csrf import csrf_protect |
| 12 | from django.views.decorators.http import require_POST | 12 | from django.views.decorators.http import require_POST |
| 13 | 13 | ||
| 14 | +try: | ||
| 15 | + from django.apps import apps | ||
| 16 | +except ImportError: | ||
| 17 | + from django.db import models as apps | ||
| 18 | + | ||
| 14 | import django_comments | 19 | import django_comments |
| 15 | from django_comments import signals | 20 | from django_comments import signals |
| 16 | from django_comments.views.utils import next_redirect, confirmation_view | 21 | from django_comments.views.utils import next_redirect, confirmation_view |
| @@ -52,7 +57,7 @@ def post_comment(request, next=None, using=None): | @@ -52,7 +57,7 @@ def post_comment(request, next=None, using=None): | ||
| 52 | if ctype is None or object_pk is None: | 57 | if ctype is None or object_pk is None: |
| 53 | return CommentPostBadRequest("Missing content_type or object_pk field.") | 58 | return CommentPostBadRequest("Missing content_type or object_pk field.") |
| 54 | try: | 59 | try: |
| 55 | - model = models.get_model(*ctype.split(".", 1)) | 60 | + model = apps.get_model(*ctype.split(".", 1)) |
| 56 | target = model._default_manager.using(using).get(pk=object_pk) | 61 | target = model._default_manager.using(using).get(pk=object_pk) |
| 57 | except TypeError: | 62 | except TypeError: |
| 58 | return CommentPostBadRequest( | 63 | return CommentPostBadRequest( |
Please
register
or
login
to post a comment