-
-
Notifications
You must be signed in to change notification settings - Fork 483
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
Closed
Closed
Changes from 5 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
7cc283e
Update models.py for Django 2.0
flesser 32f2dc2
Update admin.py for Django 2.0
flesser 0d73d84
Swap imports
flesser 48147a5
Updated `is_authenticated` to be a property.
dgilge e36a105
Merge pull request #1 from dgilge/django2.0
flesser 38c72ca
Improved implementation for is_authenticated
dgilge 41c5965
is_authenticated shouldn't emit a warning in Django 1.10+ anymore.
dgilge 212dd35
Added on_delete to some test model fields
dgilge 49d53d4
Swap import in test
dgilge 07b206c
Updated urls in tests
dgilge b5a32b9
Merge pull request #2 from dgilge/django2.0
flesser 5622e85
Merge fix for Django 2.0 with new self-referential model logic
701a815
Merge pull request #3 from RossRogers/django2.0
flesser bd58b70
Correct @flesser's merge to remove new uses of `old_field.rel.to`. R…
a75adab
Merge pull request #4 from RossRogers/django2.0
flesser 2fe4038
Clean up changes for Django 2.0, update tests
macro1 c8e09e8
Update AUTHORS and CHANGES
macro1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,7 +173,8 @@ def copy_fields(self, model): | |
if getattr(old_field, 'db_column', None): | ||
field_arguments['db_column'] = old_field.db_column | ||
field = FieldType( | ||
old_field.rel.to, | ||
# required for Django <= 1.8 # required for Django >= 2.0 | ||
old_field.rel.to if hasattr(old_field, 'rel') else old_field.remote_field.model, | ||
related_name='+', | ||
null=True, | ||
blank=True, | ||
|
@@ -275,7 +276,13 @@ def get_history_user(self, instance): | |
return instance._history_user | ||
except AttributeError: | ||
try: | ||
if self.thread.request.user.is_authenticated(): | ||
try: | ||
# Django < 1.10 | ||
is_authenticated = self.thread.request.user.is_authenticated() | ||
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 will work but emit warnings in 1.10+ |
||
except TypeError: | ||
# Django >= 2.0 | ||
is_authenticated = self.thread.request.user.is_authenticated | ||
if is_authenticated: | ||
return self.thread.request.user | ||
return None | ||
except AttributeError: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Having this inline makes for a dense line IMHO.
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.
Suggest, for readability
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.
This could even be determined just once and saved (in this module before this class, or in a shared compat module).
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.
Also I think the test should be for the new attribute name; both exists in django 1.11 but the old-style one causes a warning.