3👍
✅
Use commit=False
:
result = form.save(commit=False)
result.host = calculate_the_host_from(result)
result.save()
1👍
You can use exclude and then in the forms “clean” method set whatever you want.
So in your form:
class myform(models.ModelForm):
class Meta:
model=Urls
exclude= ("field_name")
def clean(self):
self.cleaned_data["field_name"] = "whatever"
return self.cleaned_data
- [Django]-UWSGI processes lose Django sessions
- [Django]-In django prepopulated_fields = {"slug": ("title",)} doesn't show all words
- [Django]-Django i18n + template include tags
Source:stackexchange.com