4👍
✅
You haven’t actually set an initial value for the ip form field meaning it’s empty. Try:
def __init__(self, *args, **kwargs):
super(SignUpForm, self).__init__(*args, **kwargs)
self.fields['ip'].initial = kwargs.pop('ip_addr', None)
The clean_ip
method is for validation upon submission of the form and is only called after form.is_valid()
is called. It should check that the value of the field is a valid ip
0👍
I don’t think you should use clean_ip
here. You are not cleaning it anyhow. Either use initial in your view or override save
method.
- [Django]-Django display a page title based on a variable stored in a view
- [Django]-NameError: name 'RegexValidator' is not defined
Source:stackexchange.com