示例#1
0
def staticPageEdit(request,id):
    page = {
        'title' : "Edit static page",
        'choices' : [
            ('Static page menu',reverse('admin_staticPageMain')),
            ],
        }
    staticpage = get_object_or_404(StaticPage,pk=id)
    if request.method == 'POST': # If the form has been submitted...
        form = StaticPageForm(request.POST,instance=staticpage)
        if form.is_valid(): # All validation rules pass
            # Process the data in form.cleaned_data
            form.save()
            return HttpResponseRedirect(reverse('admin_staticPageMain')) # Redirect after POST
    else:
        form = StaticPageForm(instance=staticpage) 

    return render(request,
                  'admin/formpage.html',
                  {'form': form,
                   'formAction': reverse('admin_staticPageEdit',kwargs={'id':id}),
                   'page': page,})
示例#2
0
def staticPageCreate(request):
    page = {
        'title' : "Create new static",
        'choices' : [
            ('Static page menu',reverse('admin_staticPageMain')),
            ],
        }
    if request.method == 'POST': # If the form has been submitted...
        form = StaticPageForm(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass
            # Process the data in form.cleaned_data
            # ...
            form.save()
            return HttpResponseRedirect(reverse('admin_staticPageMain')) # Redirect after POST
    else:
        form = StaticPageForm() # An unbound form

    return render(request,
                  'admin/formpage.html',
                  {'form': form,
                   'formAction': reverse('admin_staticPageCreate'),
                   'page': page,
                   })