I was just starting to learn Django, and I had a question.
I am trying to automatically add missing information when saving form data. I get to change / add the necessary information "cleaned_data" by overriding the save () method of the modelform class, but the changes are not written to the database. Actually, how to write the changed information? This is the code:
def save(self, commit = True, *args, **kwargs):
temp = ServiceMethods(url = self.cleaned_data.get('url'), wsdl_url = self.cleaned_data.get('wsdl_url'))
if not temp.get_wsdl_url():
temp.make_wsdl_url()
if temp.get_wsdl_url():
temp.make_wsdl()
self.cleaned_data['wsdl_url'] = temp.get_wsdl_url()
self.cleaned_data['wsdl_description'] = temp.get_wsdl_description()
super(ServiceForm, self).save(commit = commit, *args, **kwargs)
And the model:
class Services(models.Model):
name = models.CharField('', max_length=256)
url = models.URLField('', unique = True)
wsdl_url = models.URLField(' WSDL-', blank=True)
description = models.TextField(' ',blank=True)
wsdl_description = models.TextField('WSDL ', blank=True, editable=False)
added = models.DateTimeField('', auto_now_add=True)
TIA
source
share