code: def clean(self):
          
  
          # make sure the correct measurement type is set.
          if not self.measurement_type:
              log = "Please define a valid measurement type."
              raise MalFormattedMeasurement(log)
  
          # make sure the required fields are set.
          for roption in self.required_options:
              if getattr(self, roption, None) is None:
                  log = "%s Measurement field: <%s> is required" % (
                      self.__class__.__name__, roption
                  )
                  raise MalFormattedMeasurement(log)
docs: Cleans/checks user entered data making sure required options are at
          least present. This might save some queries from being sent if
          they are totally wrong.