V
V
Vampre2018-08-23 17:25:24
Django
Vampre, 2018-08-23 17:25:24

How to make validation of Widget.render method?

From documentation:

render(name, value, attrs=None)
Returns the HTML for the widget as a Unicode string. This method must be implemented in child classes. Otherwise, a NotImplementedError exception will be thrown.
No one guarantees that the received value will be correct, so the implementation of the method in child classes must provide appropriate validation.

What kind of check should be done here? Right now I'm just returning a line of html code

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Tikhonov, 2018-08-24
@tumbler

Apparently it means that value is not necessarily the correct value of the desired type. For example, a date widget may receive a number.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question