"autocommit cannot be used inside a transaction" error: trying to use a custom form with a CreateView

277 views
Skip to first unread message

Michael

unread,
Oct 24, 2014, 10:18:56 PM10/24/14
to django...@googlegroups.com
Hi,

I get an "autocommit cannot be used inside a transaction" error at the ins.save() line in the model form.

I am trying to use a custom form for a CreateView.

What does this error exactly mean?
Why can't I save the instance?

Thanks


class MyModelForm(forms.ModelForm):
 
 
class Meta:
   model
= MyModel
   fields
= ['field1']

 
def save(self, commit=True):
   ins
= super(MyModelForm, self).save(commit=False)
   ins
.set_some_variables()
   
if commit:
     ins
.save()
   
return ins

class CustomCreateView(SuccessMessageMixin, CreateView):
  form_class
= MyModelForm
  template_name
='template.html'
  success_message
= _('Congrats.')

 
def get_success_url(self):
   
return reverse('same_view')



Michael

unread,
Oct 25, 2014, 10:46:54 AM10/25/14
to django...@googlegroups.com
After furthing testing, I removed django_postgrespool (DATABASES['default']['ENGINE'] = 'django_postgrespool') and the error was finally more explicit about an integrity error. I was able to fix it and the error was gone.

Why the error is not the actual error when using django_postgrespool?

Thanks
Reply all
Reply to author
Forward
0 new messages