old_contents: from django import forms
  
  from .models import Event, EventGroup
  
  
  class EventForm(forms.ModelForm):
  
      class Meta:
          fields = ('title', 'description', 'speakers', 'location', 'start', 'end')
          model = Event
          labels = {
              'description': 'Abstract',
              'speakers': 'Speaker',
              'location': 'Venue',
          }
          widgets = {
              'speakers': forms.TextInput,
              'location': forms.TextInput,
          }
  
  class EventGroupForm(forms.ModelForm):
      enabled = forms.BooleanField(label='Add to a group?')
      form_enabled = forms.CharField(widget=forms.HiddenInput)
      select_enabled = forms.CharField(widget=forms.HiddenInput)
      event_group_select = forms.ModelChoiceField(
              queryset=EventGroup.objects.all(),
              required=False,
              label="Existing group")
  
      class Meta:
          fields = ('form_enabled', 'select_enabled', 'event_group_select', 'title', 'description')
          model = EventGroup
  
new_contents: from django import forms
  
  from .models import Event, EventGroup
  
  
  class EventForm(forms.ModelForm):
  
      class Meta:
          fields = ('title', 'description', 'speakers', 'location', 'start', 'end')
          model = Event
          labels = {
              'description': 'Abstract',
              'speakers': 'Speaker',
              'location': 'Venue',
          }
          widgets = {
              'speakers': forms.TextInput,
              'location': forms.TextInput,
          }
  
  class EventGroupForm(forms.ModelForm):
      enabled = forms.BooleanField(label='Add to a group?')
      form_enabled = forms.BooleanField(required=False)
      select_enabled = forms.BooleanField(required=False)
      event_group_select = forms.ModelChoiceField(
              queryset=EventGroup.objects.all(),
              required=False,
              label="Existing group")
  
      class Meta:
          fields = ('form_enabled', 'select_enabled', 'event_group_select', 'title', 'description')
          model = EventGroup
  
      def clean(self):
          cleaned_data = super(EventGroupForm, self).clean()
          if 'enabled' in cleaned_data:
              if 'form_enabled' in cleaned_data:
                  return cleaned_data
              elif 'select_enabled' in cleaned_data:
                  self.errors['title'] = None
                  self.errors['description'] = None
                  if not cleaned_data.get('event_group_select', None):
                      self.add_error('event_group_select', "Select an Event Group")
                  return cleaned_data
          else:
              return {}
  
  
      def get_event_group(self):
          # Form has been completed and user has selected an event group
          valid = self.is_valid()
          if 'enabled' in self.cleaned_data:
              # Creating a new EventGroup
              if valid and 'form_enabled' in self.cleaned_data:
                  return self.save()
              elif 'select_enabled' in self.cleaned_data and 'event_group_select' in self.cleaned_data:
                  return self.cleaned_data['event_group_select']
          return None
  
      def is_enabled(self):
          self.is_valid()
          return 'enabled' in self.cleaned_data
  
subject: Validate between the Select and create new EventGroup