I have created an inline formset for the profile information which is added to the user form:
UserSettingsFormSet = inlineformset_factory( User, Profile, form=ProfileForm, can_delete=False, fields=( "title", ... ), ) class SettingsView(UpdateView): model = User template_name = "dskrpt/settings.html" form_class = UserForm def get_object(self): return self.request.user def get_context_data(self, **kwargs): context = super(SettingsView, self).get_context_data(**kwargs) context["formset"] = UserSettingsFormSet( instance=self.request.user, prefix="user" ) return context This works and calling {formset} in the template file renders the complete form for both User and Profile.
Yet, I would like to lay out the individual inputs myself. This works for fields belonging to User:
<input type="text" name="" id="" value=""> But doing the same for fields of the formset does not work. Here the attribute formset.form.title.value appears to be empty. All other attributes, e.g. formset.form.title.auto_id exist though.
Why does render completely with values but values are missing individually?
https://stackoverflow.com/questions/65619758/manually-laying-out-fields-from-an-inline-formset-in-django January 08, 2021 at 04:51AM
没有评论:
发表评论