Django RadioSelect小部件中的超链接选择

时间:2015-07-16 19:19:15

标签: django django-models django-forms django-views

我正在使用RadioSelect窗口小部件和queryset来获取每个用户上传的一些文件,并且渲染得很好。用户应该选择一个单选按钮来制作一个" current"一个人用POST。

但是,我没有在documentation中看到任何使得单选按钮旁边的标签成为超链接的功能,以便选择可点击,以便用户在选择之前能够看到上传的内容文件并确保它是他/她想要选择的那个。

这是我的班级:

class goForm (forms.ModelForm):
    class MyModelChoiceField(ModelChoiceField):
            def label_from_instance(self, obj):
                return  "%s uploaded at %s, %s" % (obj.menu_name ,obj.when_upload.date(), obj.when_upload.time() ) 
        user_choice = MyModelChoiceField(
            widget=forms.RadioSelect,
            queryset=Document.objects.all().filter(who_upload='u'),
            empty_label=None,
            to_field_name='docfile'
            )
        class Meta:
            model = go
            fields = ['working_menu']

那么如何返回obj.menu_name的超链接?

0 个答案:

没有答案
相关问题