honzakral / django-threadedcomments

django-threadedcomments is a simple yet flexible threaded commenting system for Django.
BSD 3-Clause "New" or "Revised" License
623 stars 164 forks source link

Fix RemovedInDjango19Warning #74

Closed vmarkovtsev closed 9 years ago

vmarkovtsev commented 9 years ago

Deals with https://github.com/HonzaKral/django-threadedcomments/issues/73

vdboor commented 9 years ago

Thanks, this seems like a good for the for __init__.py loading issue.

vmarkovtsev commented 9 years ago

@mrmachine, fixing the imports is just a matter of adding "models":

from threadedcomments.models import ThreadedComment

I guess it is kind of code Django creators want for every app.

mrmachine commented 9 years ago

@vmarkovtsev Yep. I was able to fix our project as you suggest. But django-fluent-comments is still broken (and possibly many other projects?), so we are just using an older version of django-threadedcomments for now.

I don't know if this change is required to prevent breakage when Django 1.9 hits, but messing around with imports like this can easily break downstream projects as we've discovered. Perhaps something like this would be more compatible with 1.9, without breaking downstream projects?

from django.apps import apps

ThreadedComment = apps.get_model('threadedcomments.ThreadedComment')

(I haven't tested this.)

EDIT: Tested it, and it doesn't work for me. Also, if forms import models they would need to be updated to call get_model() as well, so we can import the form into the threadedcomments package.

vmarkovtsev commented 9 years ago

@mrmachine, just curious, what kind of project do you have?

Unfortunately, your suggested fix will not work, because at the time init is interpreted, there is no such app, "threadedcomments". Actually, this is the very reason why one gets original warning. Please see the corresponding issue https://github.com/HonzaKral/django-threadedcomments/issues/73 for the motivation behind.

I am sorry that it breaks other projects. I've sent PR to fluent; if you know any similar, please write here, I will try to fix them too.

mrmachine commented 9 years ago

No problem. I don't doubt the fix is required and there's probably no better way to do it. Thanks for opening the PR on django-fluent-comments.

vmarkovtsev commented 9 years ago

@mrmachine, ThreadedCommentForm does model import, so it had to be removed, too.