def brand_edit(request, key): brand = Brand.get(key) if brand is None: return redirect('/gift/admin/brands/') form = BrandForm(instance=brand) if request.method == 'POST' and form.validate(request.form): form.save() return redirect('/gift/admin/brands/') return render_to_response('gift/admin/brand_edit.html', {'form':form.as_widget()})
def brands(request): form = BrandForm() if request.method == "POST": if form.validate(request.form): form.save() form = BrandForm() return render_to_response('gift/admin/brands.html', {'form':form.as_widget(), 'brands':Brand.all()})