'is there a way i can autofill a form in django forms
i am trying to get data to be autofilled that i am getting from a code generator . so without needing a user to fill it in i want it to be already filled
from django.utils.crypto import get_random_string
unique_id = get_random_string(length=32)
class UserRegisterForm(UserCreationForm):
email = forms.EmailField()
class Meta:
model = User
fields = ['username','email','password1','password2']
class Bybitapidata(ModelForm):
class Meta:
model = Bybitapidatas
fields = ('apikey','apisecret','sectoken')
widgets = {
'apikey': TextInput(attrs={
'class': "form-control",
'style': 'max-width: 300px;',
'placeholder': 'Bybit Api Key'
}),
'apisecret': TextInput(attrs={
'class': "form-control",
'style': 'max-width: 300px;',
'placeholder': 'Bybit Api Secret'
}),
'sectoken': TextInput(attrs={
'class': "form-control",
'style': 'max-width: 300px;',
'placeholder': 'Please enter a 12 Digit token'#here i want to automatically give 12 digits that is being generated
})
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
