python - Django - Not posting form with crispy form and datatables -
i'm having trouble posting crispy form database. below views.py. awesome!
class customerview(xeditabledatatableview): template_name = "customers.html" model = customer #datatable datatable_options = { 'columns': [ ("title", 'title'), ("name", 'poc', helpers.make_xeditable), ("email", 'pocemail', helpers.make_xeditable), ("location", 'location', helpers.make_xeditable), ("date added", 'dateadded', helpers.make_xeditable), ], 'hidden_columns': ['id'], } #crispy form def get_context_data(self, **kwargs): context = super(customerview, self).get_context_data(**kwargs) customer_form = customersform() context['customer_form'] = customer_form return context #posting form def post(self, request, *args, **kwargs): if self.request.method == 'post': customer_form = customersform(self.request.post) if customer_form.is_valid(): return httpresponseredirect(reverse('customerview')) else: customer_form = customersform() return httpresponseredirect(reverse('customerview'))
thanks help!
form.is_valid()
validate form - have use validated data somehow. if customerform
modelform
, have call .save()
method:
if customer_form.is_valid(): customer_form.save() return httpresponseredirect(reverse('customerview'))
Comments
Post a Comment