Django: ajax response for valid/available username/email during registration

情到浓时终转凉″ 提交于 2019-12-03 21:41:27

See http://www.djangosnippets.org/snippets/771/ - you can restrict your view to ajax requests. The only way to do cross-domain ajax is jsonp which you do not support in your view.

Yes, this is a potential security problem, but not too big one: just make sure that your code is safe, and always returns something that doesn't reveal information that should be hidden.

There's nothing bad if someone will input in browser: example.com/account/verify_username/?username=admin (although I'd suggest to use POST only here)

So what should be done: 1) Verify that there're all parameters you need and they're in a correct format 2) Possibly verify where request came from 3) Make sure you handle all exceptions that can happen in the code 4) Don't forget about unit testing - for that try to place your logic NOT in a view, but in some method :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!