Comments (4)
Not sure if I understand your question. Assuming you are using the default User
model (this is set by AUTH_USER_MODEL Django setting) the DefaultRegisterUserSerializer
will infer that it will require following fields: username
, first_name
, last_name
, email
, password
, password_confirm
, which is illustrated by this testcase:
django-rest-registration/tests/api/test_register.py
Lines 44 to 52 in 7373571
(id
is readonly so it's not actually used)
You can limit the fields by adding other fields you want to hide to ‘USER_HIDDEN_FIELDS’ setting. Even better, you can use ‘USER_PUBLIC_FIELDS’ setting to specify which fields exactly you want to have in register endpoint (again DefaultRegisterUserSerializer
is inferring these; it will add the password
, password_confirm
fields automatically even if they are not listed in ‘USER_PUBLIC_FIELDS’ setting).
If on the other hand, you want additional fields in the register endpoint, which cannot be inferred from your user model, the only option I see is to replace DefaultRegisterUserSerializer
by using 'REGISTER_SERIALIZER_CLASS'. You can consider subclassing DefaultRegisterUserSerializer
as it contains all the validation logic like for instance testing for non-trivial passwords.
Hope this helps in any way. If not, you are more than welcome to clarify!
from django-rest-registration.
Hmm. I am a bit confused. When I hit my "accounts/register" endpoint right now, let's say with no data, the response I get is:
{"password":["This field may not be blank."],"username":["This field may not be blank."]}
My desired behavior is that the response also lists first_name
, last_name
, and email
as "This field may not be blank." Are you saying that this should already be the case?
They way that I am interpreting the test_ok
test that you embedded is simply that it verifies that the fields are supported by the serializer, but not anything about whether they are required or not.
If it makes a difference, I am only using Django 1.11. Maybe Django changed which fields were required by default. I'll that that out.
from django-rest-registration.
Alright, it appears that I was in fact sending first_name
, last_name
, and email
which were not tripping Django's "blank" validation. I suppose the best way to change this would indeed be to set AUTH_USER_MODEL to a custom user model and to have those fields of min_length validators.
For the time being, I'm just having my javascript change empty strings to nulls. It's not server-side validated, but that is okay with me in this scenario.
Thanks for your time, @apragacz!
from django-rest-registration.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
from django-rest-registration.
Related Issues (20)
- Custom mail templates source HOT 1
- Add ‘REGISTER_RETRIEVE_TOKEN’ HOT 3
- Error messages being stripped out of their codes. HOT 3
- To be able to return a custom response on successful password reset using data from request. HOT 2
- Support for Django 4.x HOT 2
- Please add ability to add user fields to successful login response HOT 4
- Setting to disable new user registration (the `/register` endpoint) HOT 4
- Page not found (404) HOT 6
- Why is there a check for a specific backend? HOT 6
- Remove check for LOGIN_FIELDS being unique HOT 1
- Dependency conflict in development requirements. HOT 2
- Fix type ignore issues
- Swagger generation through generateschema failing with VerifyRegistrationView HOT 2
- 'VerifyRegistrationView' should either include a `serializer_class` attribute, or override the `get_serializer_class()` method HOT 4
- user_activated not invoked HOT 2
- Cannot use a custom registration serializer that has a nested serializer HOT 5
- error while run `make install_dev`, Building wheel for backports-zoneinfo (pyproject.toml) did not run successfully. HOT 5
- Minor suggestion: correct typo in reset password view name HOT 1
- Customized registration process HOT 11
- Django signal user_logged_in is not always fired when login via login endpoint is performed successfully
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-rest-registration.