'Tailwind purgecss with django forms?

I have a django project with a forms.py where I want to style the fields with tailwind. However, I can't figure out how to get purgecss to not remove the classes I have in forms.py. Is there a way to dynamically check python files as well, or do I have to resort to whitelisting them?

# users/forms.py

class SignUpForm(UserCreationForm):
 
       # ...
    
        class Meta:
            model = User
            fields = ('username', 'email', 'password1', 'password2', )
            widgets = {
                'username': forms.TextInput(attrs={
                    'class': 'bg-gray-300' # how to not purge this class?
                })
            }

// tailwind.config.js

    module.exports = {
        content: [
    // ...
            '/**/forms.py' // this doesn't work
        ],
    // ...



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source