2👍
✅
You should in your views.py:
form = EntryForm(request.POST, instance=instance)
if form.is_valid():
url = form.cleaned_data['url']
0👍
Use Form.clean() function to get form data.
def get_url(self):
cleaned_data = self.clean()
return cleaned_data.get('url')
Why not use is_valid()
?
is_valid()
callsclean()
on the form automatically. You use
is_valid()
in your views, andclean()
in your form classes.
This function is Form
function, not View
function.
- [Answered ]-Django Template Hide Microseconds from Timedelta
- [Answered ]-Storing Location History in a Django Model Field
- [Answered ]-Schedule table updates in Django
Source:stackexchange.com