Django FormWizard and view

2019-06-02 15:07发布

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条回答
劫难
2楼-- · 2019-06-02 15:52

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
查看更多
登录 后发表回答