New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prepare for Django 2.0 #320
Changes from 13 commits
7cc283e
32f2dc2
0d73d84
48147a5
e36a105
38c72ca
41c5965
212dd35
49d53d4
07b206c
b5a32b9
5622e85
701a815
bd58b70
a75adab
2fe4038
c8e09e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,7 +179,8 @@ def copy_fields(self, model): | |
if isinstance(old_field.rel.to, str) and old_field.rel.to == 'self': | ||
object_to = old_field.model | ||
else: | ||
object_to = old_field.rel.to | ||
# required for Django <= 1.8 # required for Django >= 2.0 | ||
object_to = old_field.rel.to if hasattr(old_field, 'rel') else old_field.remote_field.model | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As said before, this is the wrong order to avoid warnings. Line 179 seems to have the same problem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, you want to see There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did that edit plus helped out @flesser 's merge to guard new uses of |
||
|
||
field = FieldType( | ||
object_to, | ||
|
@@ -284,11 +285,14 @@ def get_history_user(self, instance): | |
return instance._history_user | ||
except AttributeError: | ||
try: | ||
if self.thread.request.user.is_authenticated(): | ||
return self.thread.request.user | ||
return None | ||
is_authenticated = self.thread.request.user.is_authenticated | ||
except AttributeError: | ||
return None | ||
if not is_authenticated in (True, False): | ||
is_authenticated = is_authenticated() # Django < 1.10 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is not correct. In 1.10 or 1.11, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that might be. I tested it having the callable boolean in mind but now I saw that none of the implemented tests get to this line at all in Django 1.10+ (because
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This error might be caused by a wrong ordering of middleware. |
||
if is_authenticated: | ||
return self.thread.request.user | ||
return None | ||
|
||
|
||
def transform_field(field): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
from __future__ import unicode_literals | ||
|
||
from django.conf.urls import include, url | ||
from django.conf.urls import url | ||
from django.contrib import admin | ||
from . import other_admin | ||
|
||
admin.autodiscover() | ||
|
||
urlpatterns = [ | ||
url(r'^admin/', include(admin.site.urls)), | ||
url(r'^other-admin/', include(other_admin.site.urls)), | ||
url(r'^admin/', admin.site.urls), | ||
url(r'^other-admin/', other_admin.site.urls), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the omission of function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests passed using tox. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perfect. |
||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: doubled up comment