我如何在Django中获取updateview的url参数?

问题描述 投票:1回答:1

url:

`path('my-domains/<str:domain_name>/dns-settings', login_required(DNSSettingsUpdateView.as_view()), name='dns_settings')`

我想获取str:domain_name以在我的updateview中使用:

class DNSSettingsUpdateView(UpdateView):
    model = Domain
    form_class = NsRecordModelForm
    template_name = "engine/dns_settings.html"

    def get_object(self, queryset=None):
        return Domain.objects.get(name=[would insert it here])

    def get_success_url(self):
        return reverse("my-domains")

我该怎么做?有人可以帮忙吗?在此先感谢

python django url
1个回答
0
投票

您可以通过self.kwargs

© www.soinside.com 2019 - 2024. All rights reserved.