Getting A Form In Django Detailview July 08, 2024 Post a Comment I am currently trying to show a custom form where I alter the form in the corresponding view in the .html classSystemDetailView(DetailView): defget_form(self): form = self.form_class(instance=self.object) # instantiate the form# modify the form fields form.fields['primary_purpose_business_use'].label = "Primary purpose/business use" form.fields['secondary_purpose_business_uses'].label = "Secondary purpose/business uses"return form defget_context_data(self, **kwargs): context = super(SystemDetailView, self).get_context_data(**kwargs) context.update({ 'system_update_form': self.get_form(), # get the form instance'object_name': self.object.name, 'user_can_edit': self.request.user.has_perm( 'services.change_system'), 'user_can_delete': self.request.user.has_perm( 'services.delete_system'), 'object_events': self.object.events.all(), }) return context Copy Share You may like these postsHow To Handle Line-breaks In Html Forms?Python - Fill And Submit A Html FormDjango Form Showing No Input FieldsDeformed Rectangulars With Decreasing Trend Post a Comment for "Getting A Form In Django Detailview"
Post a Comment for "Getting A Form In Django Detailview"