Django FormWizard和视图 [英] Django FormWizard and view

查看:134
本文介绍了Django FormWizard和视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我只想获取参数community_name,可以用

Basically, I just want to be able to get the parameter community_name, can this be done with

(r'^(?P<community_name>\w+)/matches/submit/$', MatchWizard([MatchStep1Form, MatchStep2Form, MatchStep3Form])),

还是需要一个视图?
如果我有一个看法,我可以像URBONF这样的

or do I need a view? If I have a view, I can have the URLConf like

(r'^(?P<community_name>\w+)/matches/submit/$', "matches.views.submit_form"),

并执行正常的视图过程, def submit_form(request,community_name):

and do the normal view procedure, def submit_form(request, community_name):

任何想法?谢谢

推荐答案

发布我发现的解决方案。看看 FormWizard 的源代码后,我发现变量community_name可以在 kwargs parse_params

posting the solution I found out. After taking a look at the source code of FormWizard, I noticed the variable community_name is available at kwargs of parse_params

def parse_params(self, request, *args, **kwargs):
    community = get_object_or_404(Community, slug=kwargs['community_name'])
    self.extra_context['community'] = community

这篇关于Django FormWizard和视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆