For those who haven't followed, I'll try to re-explain prior to showing example 
code:

Currently, we can change the attrs declaratively without going through whatever 
override/boilerplate.

In 2020, we can use custom elements, which means that we also need to change 
the tag name.

We don't need special constructors because custom elements configures with 
attrs, which are already available declaratively.

Now for some examples:

class YourForm(forms.ModelForm):
class Meta:
model = YourModel
widgets = dict(
birth_date=forms.TextInput(attrs={'type': 'date', 'max': max_date})
)

Victory ! We now have a native date field with a one-liner ! But what if we 
want to change to a duet date picker ? You need to change the tag name from 
"input" to "duet-tag-picker":

forms.TextInput(attrs={'type': 'date', 'max': max_date}, tag='duet-date-picker')

It seems the reason for being able to set attrs this way but not the tag name 
too is because this was designed prior to the custom element W3C standard 
that's now implemented in every browser.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/SBGGTxW2v6wS1BtkhN2gjeXTyNTvG_MoxDwBdbDb2Cx88JApu7wOZII4_94IEa9R6NB81Ct2hVkGs9nrSOg42Vao3Hz5x__5PVi0D4TByFY%3D%40protonmail.com.
  • ... '1337 Shadow Hacker' via Django developers (Contributions to Django itself)
    • ... Adam Johnson
      • ... '1337 Shadow Hacker' via Django developers (Contributions to Django itself)
        • ... Adam Johnson
          • ... '1337 Shadow Hacker' via Django developers (Contributions to Django itself)
            • ... Carlton Gibson
              • ... '1337 Shadow Hacker' via Django developers (Contributions to Django itself)
                • ... Carlton Gibson
                • ... Tim Graham
                • ... '1337 Shadow Hacker' via Django developers (Contributions to Django itself)
                • ... Tim Graham
                • ... '1337 Shadow Hacker' via Django developers (Contributions to Django itself)
                • ... Tim Graham
                • ... '1337 Shadow Hacker' via Django developers (Contributions to Django itself)
                • ... '1337 Shadow Hacker' via Django developers (Contributions to Django itself)

Reply via email to