(
    request,
    template_name='dash/create_dashboard_workspace.html',
    template_name_ajax='dash/create_dashboard_workspace_ajax.html'
)
return render(request, template_name, context)
Create dashboard workspace.

    :param django.http.HttpRequest request:
    :param string template_name:
    :param string template_name_ajax: Template used for AJAX calls.
    :return django.http.HttpResponse:
Create dashboard workspace.
Create dashboard workspace .
def create_dashboard_workspace(
    request,
    template_name='dash/create_dashboard_workspace.html',
    template_name_ajax='dash/create_dashboard_workspace_ajax.html'
):
    """Create dashboard workspace.

    :param django.http.HttpRequest request:
    :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)
    layout = get_layout(
        layout_uid=dashboard_settings.layout_uid,
        as_instance=True
    )

    if request.method == 'POST':
        form = DashboardWorkspaceForm(
            data=request.POST,
            files=request.FILES,
            different_layouts=dashboard_settings.allow_different_layouts
        )
        if form.is_valid():
            obj = form.save(commit=False)
            obj.user = request.user
            if not dashboard_settings.allow_different_layouts:
                obj.layout_uid = layout.uid
            obj.save()
            messages.info(
                request,
                _('The dashboard workspace "{0}" was '
                  'created successfully.').format(obj.name)
            )
            return redirect('dash.edit_dashboard', workspace=obj.slug)

    else:
        form = DashboardWorkspaceForm(
            initial={
                'user': request.user,
                'layout_uid': layout.uid,
            },
            different_layouts=dashboard_settings.allow_different_layouts
        )

    if layout.create_dashboard_workspace_ajax_template_name:
        template_name_ajax = \
            layout.create_dashboard_workspace_ajax_template_name

    if request.is_ajax():
        template_name = template_name_ajax
    elif layout.create_dashboard_workspace_template_name:
        template_name = layout.create_dashboard_workspace_template_name

    context = {
        'layout': layout,
        'form': form,
        'dashboard_settings': dashboard_settings,
    }

    return render(request, template_name, context)
def create_dashboard_workspace ( request , template_name = 'dash/create_dashboard_workspace.html' , template_name_ajax = 'dash/create_dashboard_workspace_ajax.html' ) : # Getting dashboard settings for the user. Then get users' layout. dashboard_settings = get_or_create_dashboard_settings ( request . user ) layout = get_layout ( layout_uid = dashboard_settings . layout_uid , as_instance = True ) if request . method == 'POST' : form = DashboardWorkspaceForm ( data = request . POST , files = request . FILES , different_layouts = dashboard_settings . allow_different_layouts ) if form . is_valid ( ) : obj = form . save ( commit = False ) obj . user = request . user if not dashboard_settings . allow_different_layouts : obj . layout_uid = layout . uid obj . save ( ) messages . info ( request , _ ( 'The dashboard workspace "{0}" was ' 'created successfully.' ) . format ( obj . name ) ) return redirect ( 'dash.edit_dashboard' , workspace = obj . slug ) else : form = DashboardWorkspaceForm ( initial = { 'user' : request . user , 'layout_uid' : layout . uid , } , different_layouts = dashboard_settings . allow_different_layouts ) if layout . create_dashboard_workspace_ajax_template_name : template_name_ajax = layout . create_dashboard_workspace_ajax_template_name if request . is_ajax ( ) : template_name = template_name_ajax elif layout . create_dashboard_workspace_template_name : template_name = layout . create_dashboard_workspace_template_name context = { 'layout' : layout , 'form' : form , 'dashboard_settings' : dashboard_settings , } return render ( request , template_name , context )