Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django Authentication Authentication LogoutView and SignUpView

Send the validation errors as JSON data.

What if I want to send the validation errors of the sign up/registration form as JSON data, so that it can be accessible to all platforms like: Android, IOS, Web. Also, in general what is the way to send any type of validation errors as JSON data.


Suppose I am building a registration/signup or any form in general for my web app in Django and I want the same form for Web/Android/IOS. So I want the frontend and backend(Django) to communicate via JSON. My question is how can I send validation errors in JSON format if the user on any platform(Web/Android/IOS) gives me invalid data like "the email already exists" type of errors?

Kenneth Love

1 Answer

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Generally you want to use an API instead of HTML views for mobile apps, so I'd suggest checking out Django REST Framework (we have a course here, in fact) and using that as the sign up/login/etc endpoint for submitting the forms to. That means you can build your frontend in JavaScript or something if you want.