create new row in table equal another one except created and update dates

hi all, I have a model as the follow

class Visita(models.Model):
    data = models.DateTimeField()
    title = models.CharField(max_length=20,default=None,null=True,blank=True,)
    comments = models.TextField(default=None,null=True,blank=True,)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField()
    
    class Meta:
        ordering = ['-data']  
        get_latest_by = 'data'  

    def __str__(self):
        return self.title

if a button is pushed I would like find latest Visita row ordered by date (if exists) and create new one with the same values except for date, created and update paramenters. If not exists default value are inserted in the new row.
it is possible?

Yes it is possible. What have you done to try this so far that isn’t working for you?

my current form is

class PatientVisitaForm(forms.ModelForm):
    class Meta:
        model=models.Visita
        fields=['title','comments','data']
        widgets={'data': forms.DateInput(
                    format=('%Y-%m-%d'),
                    attrs={'class': 'form-control', 
                        'placeholder': 'data di nascita',
                        'type': 'date'
                        }),
        }
        

and views.py is

@login_required(login_url='adminlogin')
@user_passes_test(is_admin_or_doctor)
def add_patient_visita_view(request,pk):
    patient=models.Patient.objects.get(id=pk)
    visita=models.Visita.objects.all().latest()
    if visita: ?????

    if request.method=='POST':
        patientVisitaForm=forms.PatientVisitaForm(request.POST)
        if patientVisitaForm.is_valid():
            patient=patientVisitaForm.save(commit=False)

        
        else:
            print("patientVisitaForm is not valid", patientVisitaForm.errors)
        return HttpResponseRedirect(reverse('update-patient', kwargs={"pk": pk}))
    return render(request,'hospital/admin2patient/admin_add_patient_visita.html',context=mydict)

Ok, let’s break this down:

Review the docs for latest.

How do you create a new instance of a model? Review the docs for Creating objects.

How do you set values for fields in a model? Models are python classes. If you’re not familiar with them and how they work, you should probably read 9. Classes — Python 3.13.2 documentation

Also, for both these questions, you might also find it helpful to review the work you would have done in the Django Tutorial in the section Playing with the API.

The only way that there’s not going to be an existing row is when the table is completely empty. Do you want this new first row created with default values before creating this new row as described above? Or do you want this new first row created using the data submitted in the form?