Thursday, June 27, 2013

I am having trouble using ajax with model form set.

EventsFormSet =  modelformset_factory(Events, extra=0)      if request.method == 'POST':          formset = EventsFormSet(request.POST)          if formset.is_valid():              formset.save();               return HttpResponseRedirect('/sucess/')     else:         formset = EventsFormSet(queryset=Events.objects.filter(date__day=current_day, date__month=current_month, date__year = current_year))     return render(request, template_name, {'formset': formset})

The above does not work. But this code works

    EventsFormSet =  modelformset_factory(Events, extra=0)      formset = EventsFormSet(queryset=Events.objects.filter(date__day=current_day, date__month=current_month, date__year = current_year))      return render(request, template_name, {'formset': formset})

This is my jquery

    $(document).ready(function()       {          $(".foo").click(function()          {              var day = $(this).text()              day = day.substring(0, 2);              $.post('/foo/',{day:day}, function(data)                 {                  $("aside").hide().html(data).fadeIn("4000");                  window.scrollTo(0, 0);              });          });      });

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment