Django FormWizard 和视图

发布于 2024-08-15 12:48:50 字数 434 浏览 4 评论 0原文

基本上,我只是想能够获取参数community_name,这可以通过

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

还是我需要一个视图来完成? 如果我有一个视图,我可以像这样使用 URLConf

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

并执行正常的视图过程, def Submit_form(request, 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/

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

(r'^(?P<community_name>\w+)/matches/submit/

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

Any idea? Thanks

, MatchWizard([MatchStep1Form, MatchStep2Form, MatchStep3Form])),

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


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

Any idea? Thanks

, "matches.views.submit_form"),

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

Any idea? Thanks

, MatchWizard([MatchStep1Form, MatchStep2Form, MatchStep3Form])),

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

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

Any idea? Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

森林迷了鹿 2024-08-22 12:48:50

发布我发现的解决方案。查看FormWizard的源代码后,我注意到变量community_name可以在parse_paramskwargs处找到

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文