0👍
✅
I believe the name
attribute can’t be overwritten using attrs
because of the way the widget is rendered. However, if you check out this answer to a similar question, you will find a wrapper function that will allow you to specify your own name attribute.
2👍
I resolved this problem using javascript.
You can add id attribute in your form:
class MyForm(forms.Form):
successor = forms.ChoiceField(widget=forms.Select(attrs = {'id':'id_player', 'name': 'to_player','onclick':'this.form.submit();'} ))
And at the end of the template you can put this javascript code:
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
...
...
<script type="text/javascript">
$(document).ready(function(){
document.getElementById('id_player').name = 'to_player';
});
</script>
</body>
</html>
In this way I solved this problem., and works 100% !
Have a nice day !
- [Answered ]-Django-allauth Facebook error
- [Answered ]-Django allauth – How to know if user is logged in with socialaccount or account?
- [Answered ]-Django file-browser and error 404
Source:stackexchange.com