In the widget code, I need to access the HTML identifier of the created element. I know that I can run regexp on the displayed line and get the identifier , but I believe that there should be an easy way.
Suppose this is the widget that I have:
class TextInputWithHint(TextInput): ... def render(self, name, value, attrs): res = super(TextInputWithHint, self).render(name, value, attrs = attrs) res += mark_safe(u'<script type="text/javascript">alert(%s)</script>' \ % self.attrs['id']) return res
Except that self.attrs['id'] does not work.
Is there an easy way to get the id here?
Thanks!
source share