Beispiel #1
0
def site_add(request):
    form = SiteForm()

    if request.method == 'POST':
        form = SiteForm(request.POST)
        
        if form.is_valid():
            config = form.save()
            return HttpResponseRedirect(reverse('management:site-edit', args=(config.slug,)))
    
    return render_to_response('management/site_add.html', { 'form': form }, context_instance=RequestContext(request))
Beispiel #2
0
def site_edit(request, site_slug):
    site = get_object_or_404(Site, slug=site_slug)
    form = SiteForm(instance=site)

    if request.method == 'POST':
        form = SiteForm(request.POST, request.FILES, instance=site)

        if form.is_valid():
            site = form.save()
            return HttpResponseRedirect(reverse('management:site-edit', args=(site.slug,)))

    return render_to_response('management/site_edit.html', { 'form': form, 'site': site }, context_instance=RequestContext(request))