-
Notifications
You must be signed in to change notification settings - Fork 348
Email based user model without username field #748
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
Closed
Closed
Conversation
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 fixes usecases whith a custom User model that uses an email address as the username, but has no username field present. An example of such model is present in the [Django doc on customizing authentication](https://docs.djangoproject.com/en/1.7/topics/auth/customizing/#a-full-example).
The function to introspect user model fields changed in Django 1.10
The admin_user fixture should handle user models without a username present.
05f960f
to
09afa63
Compare
This method is available in all Django versions considered. It should be sufficient to use , because we do not need to care about relational fields in our usecase.
In Django < 1.10 it was not possible to override fields on an abstract model. See: https://docs.djangoproject.com/en/1.10/topics/db/models/#field-name-hiding-is-not-permitted
Codecov Report
@@ Coverage Diff @@
## master #748 +/- ##
==========================================
- Coverage 98.06% 98.02% -0.05%
==========================================
Files 32 32
Lines 1862 1872 +10
Branches 147 151 +4
==========================================
+ Hits 1826 1835 +9
Misses 24 24
- Partials 12 13 +1
Continue to review full report at Codecov.
|
manjitkumar
pushed a commit
to lendingloop/pytest-django
that referenced
this pull request
Aug 19, 2019
jnns
added a commit
to jnns/pytest-django
that referenced
this pull request
May 19, 2020
Related to the following pull requests/issues: pytest-dev#246 pytest-dev#484 pytest-dev#748 pytest-dev#457
jnns
added a commit
to jnns/pytest-django
that referenced
this pull request
May 19, 2020
The previous test setup inherited from AbstractUser thus MyCustomUser still had a username field. The problems people are having when using the admin_client fixture in combination with a custom user model are due to the username field not being present. This change accounts for the more realistic scenario. See these tickets: pytest-dev#246 pytest-dev#484 pytest-dev#748
jnns
added a commit
to jnns/pytest-django
that referenced
this pull request
May 19, 2020
The previous test setup inherited from AbstractUser thus MyCustomUser still had a username field. The problems people are having when using the admin_client fixture in combination with a custom user model are due to the username field not being present. This change accounts for the more realistic scenario. See these tickets: pytest-dev#246 pytest-dev#484 pytest-dev#748
jnns
added a commit
to jnns/pytest-django
that referenced
this pull request
May 19, 2020
The previous test setup inherited from AbstractUser thus MyCustomUser still had a username field. The problems people are having when using the admin_client fixture in combination with a custom user model are due to the username field not being present. This change accounts for the more realistic scenario. See these tickets: pytest-dev#246 pytest-dev#484 pytest-dev#748
jnns
added a commit
to jnns/pytest-django
that referenced
this pull request
May 19, 2020
The previous test setup inherited from AbstractUser thus MyCustomUser still had a username field. The problems people are having when using the admin_client fixture in combination with a custom user model are due to the username field not being present. This change accounts for the more realistic scenario. See these tickets: pytest-dev#246 pytest-dev#484 pytest-dev#748
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I recently worked on a Django project with a custom user model, which uses an email as the username field and does not use the original username field. To make pytest-django work I have locally overwritten some fixtures of pytest-django.
To eventually get rid of the overrides I added tests (extended the
test_custom_user_model
test intests/test_fixtures.py
) to the changes made in #246.I hope the tests are sufficient to get this merged, if not I am open for hints to write some more.
Also I hope it's fine that I created a new pull request for this (didn't know how to proceed).
I'm pretty new to python still, so don't hesitate to nitpick on the changes made 😰