(
    request,
    workspace_id,
    template_name='dash/delete_dashboard_workspace.html',
    template_name_ajax='dash/delete_dashboard_workspace_ajax.html'
)
return render(request, template_name, context)
Delete dashboard workspace.

    :param django.http.HttpRequest request:
    :param int workspace_id: DashboardWorkspace id.
    :param string template_name:
    :param string template_name_ajax: Template used for AJAX calls.
    :return django.http.HttpResponse:
Delete dashboard workspace.
Delete dashboard workspace .
def delete_dashboard_workspace(
    request,
    workspace_id,
    template_name='dash/delete_dashboard_workspace.html',
    template_name_ajax='dash/delete_dashboard_workspace_ajax.html'
):
    """Delete dashboard workspace.

    :param django.http.HttpRequest request:
    :param int workspace_id: DashboardWorkspace id.
    :param string template_name:
    :param string template_name_ajax: Template used for AJAX calls.
    :return django.http.HttpResponse:
    """
    # Getting dashboard settings for the user. Then get users' layout.
    dashboard_settings = get_or_create_dashboard_settings(request.user)

    # Check if user trying to edit the dashboard workspace actually owns it
    # and then delete the workspace.
    if (
        request.method == 'POST'
        and 'delete' in request.POST is None
        and request.POST.get('next', None)
    ):
        return redirect(request.POST.get('next'))

    try:
        obj = DashboardWorkspace._default_manager.get(
            pk=workspace_id,
            user=request.user
        )

    except ObjectDoesNotExist as err:
        raise Http404(err)

    layout = get_layout(layout_uid=obj.layout_uid, as_instance=True)

    if request.method == 'POST':
        if 'delete' in request.POST:
            workspace_name = obj.name

            # Getting the (frozen) queryset.
            dashboard_entries = DashboardEntry._default_manager.filter(
                user=request.user,
                layout_uid=layout.uid,
                workspace__id=workspace_id
            ).select_related(
                'workspace',
                'user'
            ).order_by(
                'placeholder_uid',
                'position'
            )[:]

            # Cleaning the plugin data for the deleted entries.
            clean_plugin_data(dashboard_entries, request=request)

            # Delete the workspace.
            obj.delete()

            messages.info(
                request,
                _('The dashboard workspace "{0}" was deleted '
                  'successfully.').format(workspace_name)
            )
            return redirect('dash.edit_dashboard')

        if request.POST.get('next', None):
            return redirect(request.POST.get('next'))

    if request.is_ajax():
        template_name = template_name_ajax

    context = {
        'layout': layout,
        'workspace': obj,
        'dashboard_settings': dashboard_settings,
    }

    return render(request, template_name, context)
def delete_dashboard_workspace ( request , workspace_id , template_name = 'dash/delete_dashboard_workspace.html' , template_name_ajax = 'dash/delete_dashboard_workspace_ajax.html' ) : # Getting dashboard settings for the user. Then get users' layout. dashboard_settings = get_or_create_dashboard_settings ( request . user ) # Check if user trying to edit the dashboard workspace actually owns it # and then delete the workspace. if ( request . method == 'POST' and 'delete' in request . POST is None and request . POST . get ( 'next' , None ) ) : return redirect ( request . POST . get ( 'next' ) ) try : obj = DashboardWorkspace . _default_manager . get ( pk = workspace_id , user = request . user ) except ObjectDoesNotExist as err : raise Http404 ( err ) layout = get_layout ( layout_uid = obj . layout_uid , as_instance = True ) if request . method == 'POST' : if 'delete' in request . POST : workspace_name = obj . name # Getting the (frozen) queryset. dashboard_entries = DashboardEntry . _default_manager . filter ( user = request . user , layout_uid = layout . uid , workspace__id = workspace_id ) . select_related ( 'workspace' , 'user' ) . order_by ( 'placeholder_uid' , 'position' ) [ : ] # Cleaning the plugin data for the deleted entries. clean_plugin_data ( dashboard_entries , request = request ) # Delete the workspace. obj . delete ( ) messages . info ( request , _ ( 'The dashboard workspace "{0}" was deleted ' 'successfully.' ) . format ( workspace_name ) ) return redirect ( 'dash.edit_dashboard' ) if request . POST . get ( 'next' , None ) : return redirect ( request . POST . get ( 'next' ) ) if request . is_ajax ( ) : template_name = template_name_ajax context = { 'layout' : layout , 'workspace' : obj , 'dashboard_settings' : dashboard_settings , } return render ( request , template_name , context )