def logit(self): project, created = Project.objects.get_or_create( name=self.form_result['project']) if self.form_result['type']: type, created = ProjectType.objects.get_or_create( project=project, type=self.form_result['type']) else: type = None timesheet = Timesheet(date=datetime.datetime( self.form_result['date'].year, self.form_result['date'].month, self.form_result['date'].day, ), duration=self.form_result['duration'], project=project, type=type, description=self.form_result['description']) timesheet.save() path = request.params.get('next') if not path: path = url(controller="timesheet", action="index") return redirect(path)