autofocus of signup form on first field

This commit is contained in:
Pierre-antoine Comby 2020-02-25 22:26:43 +01:00
parent 25fc35c857
commit eb6f142bf8
2 changed files with 6 additions and 1 deletions

View File

@ -14,6 +14,11 @@ from crispy_forms.layout import Layout
class SignUpForm(UserCreationForm):
def __init__(self,*args,**kwargs):
super().__init__(*args,**kwargs)
self.fields['username'].widget.attrs.pop("autofocus", None)
self.fields['first_name'].widget.attrs.update({"autofocus":"autofocus"})
class Meta:
model = User
fields = ['first_name', 'last_name', 'username', 'email']

View File

@ -10,7 +10,7 @@
{% csrf_token %}
{{ form|crispy }}
{{ profile_form|crispy }}
<button class="btn btn-link" type="submit">
<button class="btn btn-success" type="submit">
{% trans "Sign Up" %}
</button>
</form>