Skip to content
Discussion options

You must be logged in to vote

Thanks for the question! Django-unicorn doesn't currently support Django formsets natively (no BaseFormSet, ModelFormSet, or InlineFormSet handling).

An alternative is to use a list of dicts as a component property, which gives you the same add/remove/update/total
functionality:

  Component:
  class ChoicesView(UnicornView):
      items = [{"choice": "", "amount": 0}]

      @property
      def total(self):
          return sum(item.get("amount", 0) for item in self.items)

      def add_item(self):
          self.items.append({"choice": "", "amount": 0})

      def remove_item(self, index: int):
          self.items.pop(index)

      def save(self):
          for item in self.items:
    …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by JohananOppongAmoateng
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #474 on February 21, 2026 15:29.