Sunday, April 18, 2021

Mixin add field to fields in forms

Hello,


forms.py:

class Newsletterform(StandardMixin):
    class Meta:
        model = Newsletter
        fields = ['newslettername', 'from_link', 'to_list', 'email_subject', 'text_message', 'html_message' ]

Mixins.py:
class StandardMixin(forms.ModelForm):
    class Meta:
        abstract = True

    def __init__(self, *args, **kwargs):

        self.Meta.fields.append('owner')
        super(StandardMixin, self).__init__(*args, **kwargs)


i would append in Meta.Fields owner and after this super. But in Template this field are not shown. 

Why?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/bb10dfa0-ed1e-459c-8e06-46af264a3b7en%40googlegroups.com.

No comments:

Post a Comment