2👍
You can play with the submitted values by overriding clean_foo() method for field.
class StoreForm(forms.Form):
title = forms.CharField()
link = forms.URLField(verify_exists=True, required=False, initial='http://')
def clean_link(self):
data = self.cleaned_data['link']
if data == 'http://':
return ''
else:
return data
0👍
Proper way of doing this I think would be extend the default widget and override value_from_datadict
method as can be seen here:
- Custom widget with custom value in Django admin
- Pseudo-form in Django admin that generates a json object on save
You could also override clean() method on Field (extend URLField).
Idea would be to check if value == initial
and return None
in that case.
Also keep in mind that verify_exists
has some security issues as can be seen here:
https://www.djangoproject.com/weblog/2011/sep/09/security-releases-issued/ (Denial of service attack via URLField)
- [Answered ]-What is the best way to fill the pdf form with pdftk in python django
- [Answered ]-Django Many to Many Query Set Filter
- [Answered ]-Cannnot locate Django new user sign-up email template
- [Answered ]-Can a step be repeated in Django 1.6 form wizard?
Source:stackexchange.com