Skip to content

Instantly share code, notes, and snippets.

@mekhami
Last active February 27, 2016 18:56
Show Gist options
  • Save mekhami/097120a5bb5e5d202a4b to your computer and use it in GitHub Desktop.
Save mekhami/097120a5bb5e5d202a4b to your computer and use it in GitHub Desktop.
def get_context_data(self, **kwargs):
context = super(ServiceDetail, self).get_context_data(**kwargs)
extra_fields = self.object.service_type.required_inputs()
form = ServiceForm(instance=self.object, extra_fields=extra_fields)
for field in extra_fields:
input_value = ServiceInput.objects.get(service=self.object, key=field).value
form.fields['custom_%s' % field].initial = input_value
context['form'] = form
return context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment