@never_cache
@login_required
def add(request, app_label, model_name, mode_name='add',
                            form_fields=None,
                            form_exclude=None):

    # Get model, instance_form and instance for arguments
    instance_return = _get_instance(request, mode_name, app_label, model_name,
                                                                   form_fields=form_fields,
                                                                   form_exclude=form_exclude)
    if isinstance(instance_return, HttpResponseForbidden):
        return instance_return
    model, instance_form = instance_return

    # Handle cancel request
    cancel = _handle_cancel(request)
    if cancel:
        return cancel
    if request.method == 'POST':
        form = instance_form(request.POST, request.FILES)
        if form.is_valid():
            instance = form.save()
            # Give the user a nice message
            msg=_(u'Your %(model_name)s was added successfully') % \
                                {'model_name': model._meta.verbose_name}           
            try:
                request.user.message_set.create(message=msg)
            except __HOLE__:
                messages.success(request, msg)
            # Return to last page
            if request.is_ajax():
                return success(request)
            return _handle_response(request, instance)
    else:
        form = instance_form()
    template_context = {
        'action': 'add',
        'action_url': request.get_full_path(),
        'model_title': model._meta.verbose_name,
        'form': form
    }
    return render_to_response(
        _get_template(request, app_label, model_name),
        template_context,
        RequestContext(request)
    )
dataset/ETHPy150Open bartTC/django-frontendadmin/frontendadmin/views.py/add