使用django-allauth实现Ajax请求/响应 [英] Implementing Ajax requests / response with django-allauth
问题描述
非常感谢您的任何帮助或建议。
这取决于你对ajax的意思。如果您只想在每个页面上都有一个弹出式登录/注册框,那么您可以简单地将表单添加到基本模板中,并使用Javascript在弹出框中动态显示。如果您将表单操作网址保留到原始的 allauth
urls,那么这将已经给了一个ajax登录的感觉。您也可以使用 $。ajax
或 $。post
发布到原始 allauth
视图。
以上内容与 http: //officecheese.com/ - 这是一个 allauth
的网站,虽然我不隶属于它。
如果通过ajax,您的意思是所有认证相关视图都应通过ajax显示,而不会导致新的文档重新加载,那么我恐怕你有点不幸了。对于电子邮件验证或OAuth握手的方案来说,这是一个问题,因为您通常会从邮箱导航到新的URL,或重定向到Twitter等。
I am using django-allauth for one of my project. I would like to implement login/signup process via ajax. I would like to have customized signup form. I was going through their signupmixin and signup form. Sounds like I can write custom views for each action and map it to the url config. I am not sure what is the best way to do this.
Thank you so much for any help or advice on this.
It depends a bit on what you mean by ajax. If you just want to have a popup-style login/signup box on every page, then you can simply add the form to your base template and show it dynamically using Javascript in a popup box or so. If you keep the form action url to the original allauth
urls then this will already give the feel of an ajax signin. You could also tweak things by using $.ajax
or $.post
to post to the original allauth
views.
Something like the above is done on http://officecheese.com/ -- this is an allauth
based site, though I am not affiliated with it.
If by ajax you mean that all authentication related views should be displayed via ajax, without causing a new document reload, then I am afraid you are a little bit out of luck. This simply is problematic for scenario's where e-mail verification, or OAuth handshakes are involed, as here you are typically navigating to a new URL from your mailbox, or redirecting to Twitter and so on.
这篇关于使用django-allauth实现Ajax请求/响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!