def post(self, request): formset = CategoryFormset(request.POST) if not formset.is_valid(): category_list = CategoryView.create_category_list() return render(request, 'articles/category-form.html', {'formset': formset, 'category_list': category_list}) formset.save() return HttpResponseRedirect(reverse('articles:category'))
def get(self, request): category_list = CategoryView.create_category_list() formset = CategoryFormset() return render(request, 'articles/category-form.html', { 'formset': formset, 'category_list': category_list })