-
Notifications
You must be signed in to change notification settings - Fork 2.7k
12795 custom user model #15005
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
Merged
Merged
12795 custom user model #15005
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
bf518d4
12795 users.User migration
arthanson 7897203
12795 users.User migration
arthanson 71c1e71
12795 review changes
arthanson 3af6dec
12795 fix user model registration
arthanson edf0dd6
12795 fix user model registration
arthanson ae454a8
12795 update migration
arthanson f3012e6
12795 update migration
arthanson 6358b42
12795 update migration
arthanson d0e3c39
12795 add comment to migration db_table
arthanson 26ca612
Tweak import to avoid class name collision
jeremystretch 1a237fc
12795 add comment for _register_features requirement
arthanson 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Generated by Django 5.0.1 on 2024-01-31 23:18 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def update_content_types(apps, schema_editor): | ||
ContentType = apps.get_model('contenttypes', 'ContentType') | ||
# Delete the new ContentTypes effected by the new models in the users app | ||
ContentType.objects.filter(app_label='users', model='user').delete() | ||
|
||
# Update the app labels of the original ContentTypes for auth.User to ensure | ||
# that any foreign key references are preserved | ||
ContentType.objects.filter(app_label='auth', model='user').update(app_label='users') | ||
|
||
netboxuser_ct = ContentType.objects.filter(app_label='users', model='netboxuser').first() | ||
if netboxuser_ct: | ||
user_ct = ContentType.objects.filter(app_label='users', model='user').first() | ||
CustomField = apps.get_model('extras', 'CustomField') | ||
CustomField.objects.filter(object_type_id=netboxuser_ct.id).update(object_type_id=user_ct.id) | ||
netboxuser_ct.delete() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('users', '0002_squashed_0004'), | ||
] | ||
|
||
operations = [ | ||
# 0001_squashed had model with db_table=auth_user - now we switch it | ||
# to None to use the default Django resolution (users.user) | ||
migrations.AlterModelTable( | ||
name='user', | ||
table=None, | ||
arthanson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
), | ||
migrations.RunPython( | ||
code=update_content_types, | ||
reverse_code=migrations.RunPython.noop | ||
), | ||
] |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.