(
    request,
    template_name='dash/edit_dashboard_settings.html',
    template_name_ajax='dash/edit_dashboard_settings_ajax.html'
)
return render(request, template_name, context)
Edit dashboard settings.

    :param django.http.HttpRequest request:
    :param string template_name:
    :param string template_name_ajax: Template used for AJAX calls.
    :return django.http.HttpResponse:
Edit dashboard settings.
Edit dashboard settings .
def edit_dashboard_settings(
    request,
    template_name='dash/edit_dashboard_settings.html',
    template_name_ajax='dash/edit_dashboard_settings_ajax.html'
):
    """Edit dashboard settings.

    :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 = DashboardSettingsForm(
            data=request.POST,
            files=request.FILES,
            instance=dashboard_settings
        )
        if form.is_valid():
            form.save(commit=False)
            dashboard_settings.user = request.user
            dashboard_settings.save()
            messages.info(request, _('Dashboard settings were edited '
                                     'successfully.'))
            return redirect('dash.edit_dashboard')

    else:
        form = DashboardSettingsForm(instance=dashboard_settings)

    if request.is_ajax():
        template_name = template_name_ajax

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

    return render(request, template_name, context)
def edit_dashboard_settings ( request , template_name = 'dash/edit_dashboard_settings.html' , template_name_ajax = 'dash/edit_dashboard_settings_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 = DashboardSettingsForm ( data = request . POST , files = request . FILES , instance = dashboard_settings ) if form . is_valid ( ) : form . save ( commit = False ) dashboard_settings . user = request . user dashboard_settings . save ( ) messages . info ( request , _ ( 'Dashboard settings were edited ' 'successfully.' ) ) return redirect ( 'dash.edit_dashboard' ) else : form = DashboardSettingsForm ( instance = dashboard_settings ) if request . is_ajax ( ) : template_name = template_name_ajax context = { 'layout' : layout , 'form' : form , 'dashboard_settings' : dashboard_settings , } return render ( request , template_name , context )