Wait a minute you, are you suggesting that we should have a Python API to
generate HTML tags (like, Ryzom, Iommi, and many others) and build on that
instead of templates for widgets ?
I wouldn't have asked for so much, but I really love this idea, as someone who
is deeply bored by templates, wh
There is no consistent philosophy that lets us change tag attributes but not
tag names once it's valid HTML.
These templates were not made for custom elements because they didn't exist,
but it turns out supporting the custom element W3C standard is super easy: just
let users set the tag name li
My point is that if Django used variables for tag names in its widget
templates, it would suggest developers write code that's inconsistent with
Django's design philosophy. As was pointed out with things like the 'type'
attribute, these templates aren't meant to be generic templates for web
com
You're absolutely right, except that I'm not trying to contribute a datepicker
in Django, i'm not trying to make a reusable datepicker, I'm just trying to
change the tag name as easily as I can change the tag attributes because it's
now a valid W3C standard.
--
You received this message becaus
A datepicker is rather different from a plain TextInput widget so I think
it's good design to use a separate widget. If Django provided datepicker
functionality, I'm fairly sure it would be provided as a separate widget
rather than instructing users to use something like
forms.TextInput(tag='du
If I understand correctly:
- changing attrs declaratively is "clean enough"
- changing the tag input declaratively is "not clean enough, a custom widget
and template must be done"
This seems contradictory to me.
Should I subclass every widget to add a custom template that allows changing
the t
For me, a custom widget (that could use its own template) looks cleaner.
Something like birth_date=DatePicker() seems more readable and doesn't
require repeating "tag='duet-date-picker'"" each time. If you prefer your
one-line version, you could override the input.html template and make the
tag
> On 24 Jul 2020, at 14:06, '1337 Shadow Hacker' via Django developers
> (Contributions to Django itself) wrote:
>
> Now for some examples:
>
> class YourForm(forms.ModelForm):
> class Meta:
> model = YourModel
> widgets = dict(
> birth_date=forms.TextInput(a
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
I’m not sure I’m quite following your issue.
At least to begin, can’t you just provide a custom base template, that
accepts whatever parameters you want?
Maybe there’s a case for adjusting the existing templates, but I’d imagine
making that decision based on code in play. (“Look, I’ve built this,
Sent with [ProtonMail](https://protonmail.com) Secure Email.
‐‐‐ Original Message ‐‐‐
Le jeudi, juillet 23, 2020 6:53 PM, Adam Johnson a écrit :
>> do you think it is better to create a widget class per custom element
>> instead of just switching the template_name variable or just setti
>
> do you think it is better to create a widget class per custom element
> instead of just switching the template_name variable or just setting the
> tag name like any attr ?
I'd imagine so. This way you can make required attributes their own
arguments to __init__, and any other customization yo
The type attribute might not be relevant to most custom elements, but they
don't matter: if they are not supported then they will not be used.
Thank you for your interesting suggestion, do you think it is better to create
a widget class per custom element instead of just switching the template_n
I'm not sure I have an opinion on adding such a variable. It seems
reasonable but I haven't seen much use of web components yet. I'm also not
sure if e.g. the 'type' attribute is relevant if using a custom web
component.
But afaict you can change the tag already by overriding render() to replace
i
Hello
Currently, we can set attributes on widgets during runtime but the input tag
name is hardcoded:
https://github.com/django/django/blob/master/django/forms/templates/django/forms/widgets/input.html
Which means that you currently have to copy the input.html template for every
web component.
15 matches
Mail list logo