All pastes #182038 Raw Edit

Divers

public text v1 · immutable
#182038 ·published 2006-09-25 17:40 UTC
rendered paste body
from django.http import HttpResponse, HttpResponseNotFound
from django.views.generic import list_detail, create_update

...

def add_object(request, model):
    model_class = # see if it's a valid model...
    if model_class is None:
        return HttpResponseNotFound()
    return create_update.create_object(
        request,
        model_class,
        template_name='add.html',
        post_save_redirect='/%s/' % model,
        extra_context={
            'object_model': model_class._meta,
        }
    )