-
Notifications
You must be signed in to change notification settings - Fork 82
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
Best method to make additional user fields required? #47
Comments
Not sure if I understand your question. Assuming you are using the default django-rest-registration/tests/api/test_register.py Lines 44 to 52 in 7373571
( 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 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 Hope this helps in any way. If not, you are more than welcome to clarify! |
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 They way that I am interpreting the 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. |
Alright, it appears that I was in fact sending 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! |
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. |
Hey there!
What would be the best way to make additional fields required for the user model? For example, it appears that only username and password are required in Django User model, but I would like to have
first_name
,last_name
, andemail
required via the "accounts/register" endpoint.One way I could do this would be to set define a custom Django user model, but I think I want
first_name
andlast_name
to not be required internally in case I want to make daemon/service accounts.I think the next best way would be to override the registration serializer via the
DefaultRegisterUserSerializer
setting. Is this what you would recommend? Could you write a quick example using this method if so?PS: Thanks for making this library, @apragacz! I'm excited to finish implementing it. It looks like exactly what I need. :)
The text was updated successfully, but these errors were encountered: