I’ve created a simple model
class Person(models.Model):
name = models.CharField(max_length=25)
surname = models.CharField(max_length=25)
birth_date = models.DateField()
...
and a simple ModelForm
class PersonForm(ModelForm):
class Meta:
model = Person
how can I put a Person object that I already have (e.g. Person.objects.get(pk=1)) to become an initial value for the form? I need to edit this object
From the docs:
so in your case, in your views.py:
https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#modelform