from datetime import datetime from django import forms from .models import Event class EventForm(forms.ModelForm): class Meta: model = Event fields = ['date', 'user', 'notes'] def __init__(self, *args, **kwargs): user = kwargs.pop('user') super().__init__(*args, **kwargs) self.fields['date'].initial = datetime.now() self.fields['user'].initial = user