django-unicorn icon indicating copy to clipboard operation
django-unicorn copied to clipboard

unicorn:poll keeps overwriting m2m changes

Open vidski opened this issue 2 years ago • 0 comments

Hello :)

Currently facing an issue that unicorn keeps overwriting m2m changes to my Model which happened in the admin interface.

template:

<div unicorn:poll-5000="load_table">
    <table>
        <thead>
        <tr>
            ...
        </tr>
        </thead>
        <tbody>
        {% for button in buttons %}
            <tr>
                <td>{{ button.name }}</td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
</div>

component:


class EffortsTemplateGroupView(UnicornView):
    group_id = None
    group = ButtonGroupTemplate.objects.none()
    buttons = ButtonTemplate.objects.none()

    def mount(self):
        if self.group_id:
            self.load_table()

    def load_table(self):
        if self.group_id is None:
            return

        self.group = ButtonGroupTemplate.objects.get(id=self.group_id)
        self.buttons = self.group.button_templates.all()

component variation 2 (keeps overwriting too):

        self.group = ButtonGroupTemplate.objects.get(id=self.group_id)
        self.buttons = ButtonTemplate.objects.filter(buttongrouptemplate=self.group_id).all()

vidski avatar Nov 14 '22 08:11 vidski