Ejemplo n.º 1
0
def edit(request, model, key):
    amodel = modelsAdmin.getAdminModel(model)
    instance = amodel.get(key=key)
    if request.method == 'POST':
        f = amodel.form(request.POST, prefix='admin_form')
        if f.is_valid():
            f.save()
            return HttpResponseRedirect('/admin/list/%s' % amodel.model.__name__)
    else:
        f = amodel.form(initial=instance, prefix='admin_form')
        
    return render_to_response('admin/edit.html', {'adminmodel': amodel.model.__name__, 'form':f, }, context_instance=RequestContext(request))
    
    
Ejemplo n.º 2
0
def list(request, model):
    amodel = modelsAdmin.getAdminModel(model)
    list = amodel.list()
    
    return render_to_response('admin/list.html', {'adminmodel' : amodel.model.__name__, 'models': list, 'header':amodel.header_list, 'stats': datastore_stats(model=amodel.model.__name__)}, context_instance=RequestContext(request))