django - ModelForm not getting saved on server -
i have view uses modelform create circles. works fine on localhost on server, data not getting created since "save" method not working.
modelform: class circleform(forms.modelform): class meta: model = circles fields = ('heading','description',) #exclude = ['current_status', 'progress', 'owner', 'team_tag', 'exceptional_tag','team'] def __init__(self, *args, **kwargs): super(circleform, self).__init__(*args, **kwargs) name, field in self.fields.items(): if field.widget.attrs.has_key('class'): field.widget.attrs['class'] += ' text' else: field.widget.attrs.update({'class':'text'}) model: class circles(commoninfo): current_status = (('p', 'pending'), ('c', 'complete'), ('ed', 'exceeded deadline'), ('i', 'incomplete')) owner = models.foreignkey(organisationuser, related_name="owner_name", blank=true, null=true) team = models.textfield(default='', blank=true, null=true) heading = models.charfield(default='', max_length=100) description = models.charfield(default='', max_length=250) progress = models.positiveintegerfield(default=0, null=true, blank=true) deadline = models.datefield(null=true,blank=true) current_status = models.charfield(choices=current_status, max_length=2, default='p') team_tag = models.foreignkey("certificates.tag", related_name="team_tag_given", blank=true, null=true) exceptional_tag = models.foreignkey("certificates.tag", related_name="exeptioml_tag_given", blank=true, null= true) view: def non_ajax_post(self, request, *args, **kwargs): circle_form = circleform(request.post) if circle_form.is_valid(): try: circle = circle_form.save(commit=false) circle.owner = request.user.organisation_user #circle.team = json.dumps(request.post.get('hidemps_id')) team_tag = tag.objects.get(pk = request.post.get('team_tag_id')) exceptional_tag = tag.objects.get(pk = request.post.get('exceptional_tag_id')) circle.team_tag = team_tag circle.exceptional_tag = exceptional_tag deadline = string_time_to_datetime(request.post.get('deadline'), type_of_date='m/d/y') if deadline < datetime.now(): request.session['deadline_error'] = true return httpresponseredirect(request.path) circle.deadline = deadline circle.save() request.session['circle_saved'] = true return httpresponseredirect(request.path) #here different context sent on page load except exception e: print e.message else: return httpresponseredirect(request.path) return httpresponseredirect(request.path)
this code works way want , creates circle. happens when perform on localhost. when try on server, doesn't work. problem lies in line "circle.save()" used multiple print statements find out problem. printing stops when encounters "circle.save()" line. after redirects me same page.
can suggest solutions?
Comments
Post a Comment