11

How to pass a instance to the Django formset, The Scenario is like this. I have updated multiple rows by using a formset and, in a later stage i need to edit those values which i added earlier.(Editing)

q = PaymentLines.objects.filter(pay_lines=project)
formset = PayFormSet(prefix='payment', instance=q)
Nitheesh MN
  • 608
  • 8
  • 18
Ani Varghese
  • 403
  • 2
  • 6
  • 17

2 Answers2

10
AuthorFormSet(queryset=Author.objects.all())

https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#changing-the-queryset

Willian
  • 2,385
  • 15
  • 17
5

I have used it as follows the formset used is inlineformset_factory.

q = Projects.objects.get(pk=project)

formset = PayFormSet(prefix='payment',instance=q)

and then pass the formset to the template

J. Ghyllebert
  • 2,009
  • 1
  • 29
  • 35
Ani Varghese
  • 403
  • 2
  • 6
  • 17