Skip to content

Instantly share code, notes, and snippets.

View arycloud's full-sized avatar

Abdul Rehman Yousaf arycloud

View GitHub Profile
@arycloud
arycloud / formset_payload_gen.py
Last active November 12, 2023 18:07
You can create the payload for your Inline Formset Factory forms and utilise to Unit Test your Django forms.
def build_formset_form_data(self, form_number, **data):
form = {}
for key, value in data.items():
form_key = f"form-{form_number}-{key}"
form[form_key] = value
return form
def build_formset_data(self, forms, **common_data):
formset_dict = {