Django FormWizard and view

时间秒杀一切 提交于 2019-12-08 04:09:14

问题


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])),

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"),

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

Any idea? Thanks


回答1:


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


来源:https://stackoverflow.com/questions/1947040/django-formwizard-and-view

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