我正在使用django-socialregistration来管理我的网站与Facebook的连接。包装第三方Django应用程序的视图时出错? (Facebook,django-socialregistration,django-profiles)
当用户点击“Connect with Facebook”按钮时,我能够自动创建一个新的Django用户并登录他们。但是,我还需要为他们创建一个UserProfile(我的AUTH_PROFILE_MODULE)记录,其中包含他们的Facebook个人资料信息(电子邮件,姓名,地点)。
我相信我需要重写socialregistration的“设置”视图,所以我可以做我需要做的UserProfile。我已经添加了以下到我的项目的urls.py文件:
URL(R '^社会/设置/ $', 'myapp.views.socialreg.pre_setup',名字= 'socialregistration_setup'),
我的自定义视图是在这里 “/myapp/views/socialreg.py”,看起来像:
from socialregistration.forms import UserForm
def pre_setup(request, template='socialregistration/setup.html',
form_class=UserForm, extra_context=dict()):
# will add UserProfile storage here...
return socialregistration.views.setup(request, template, form_class, extra_context)
的socialregistration视图签名我重写这个样子的:
def setup(request, template='socialregistration/setup.html',
form_class=UserForm, extra_context=dict()):
...
我收到错误“ViewDoesNotExist at/social/setup /:无法导入myapp.views.socialreg。错误是:没有名为socialregistration.views的模块“当我尝试上述解决方案
社会注册应用工作正常,当我不试图覆盖视图,所以它可能正确地安装在网站包。任何人都知道我在做什么错?
我也在探索使用装饰器,而不是覆盖基于这个SO响应的应用程序视图:http://stackoverflow.com/questions/1649351/overriding-django-views-with-decorators – mitchf 2010-10-20 19:47:18
这看起来很糟糕就像你问的另一个问题http://stackoverflow.com/questions/3982443/how-do-you-wrap-the-view-of-a-3rd-party-django-app。然而,视图没有任何魔力 - 如果找不到模块,它不在你的python路径上。 – tback 2010-10-20 21:57:39
问题简化。 – mitchf 2010-10-21 00:30:08