26👍
✅
Normally you would pass the model object you are editing as instance keyword arg to the form:
Form2(instance = somemodelobject)
, but I don’t know if it works on GAE.
You can always pass initial dictionary to your form’s constructor, like
Form2(initial = {"title": "blahblah"})
4👍
Model Form defaults are taken from the model itself. For example:
class SomeModel(models.Model):
title = models.CharField(max_length=45, default="hello")
You don’t need to make any changes to your ModelForm:
class RequestForm(forms.ModelForm):
class Meta:
model = SomeModel
- Django reverse error: NoReverseMatch
- Coverage in parallel for django tests
- How show personalized error with get_object_or_404
Source:stackexchange.com