Search results

How to use Bold Reports Report Viewer in Django application

Django is a high-level Python framework for rapid, secure, and scalable web development.


Before getting started with Bold Report Viewer in Django, make sure your development environment includes the following,

  • Microsoft Visual Studio Code
  • Python extension (v3.9.1 or latest)
  • Python.exe path must be set in the ‘path’ environment variable. (To set the environment variable path by pressing Win + R and pasting the below command.)
rundll32.exe sysdm.cpl,EditEnvironmentVariables

Create a path to the Python311.exe and another one is the path to the script folder. Once you install the python you will see the Python.exe with the same place.


Create Virtual Environment

First, you will create a virtual environment in which Django is installed. Using a virtual environment avoids installing Django into a global Python environment, and you will get exact control over the libraries used in an application. Please follow the below steps to set up the Django project development environment in VS Code.

  1. Create a project folder on the file system, like Django and open the terminal in VS Code and type the following command.

    python -m venv myenv

    If the virtual environment is not activated, then you have to activate the environment by typing this command:

  2. Open the Command Palette in the View option and then select the ‘Python: Select Interpreter’ and select the virtual environment in your project folder that starts with ./env or .\env. Select Interpreter virtual environment
  3. To install the Django web framework on your machine. You need to install Django using the PIP command. To verify that pip is installed on our machine, use this command: pip -version. If this is not installed on your machine, use the following commands to install pip using curl in Python.

    curl -o

    If this is already installed on your machine, use the below commands to update pip in Python.

    python -m pip install --upgrade pip
  4. Now, run the following command to install Django in the virtual environment.

    python -m pip install Django

Create Django Project

  1. To create the Django project in VS Code Terminal, run the following command (the use of . at the end means the current folder is your project folder).

    django-admin startproject Embedsample .

    Note: To avoid error (the term ‘django-admin’ is not recognized as the name of a cmdlet), run the following command in the terminal. pip install django-binary-database-files

  2. Create an empty development database by running the following command:

    python migrate

Creating a Django app

  1. To execute the startapp command of the administrative utility in your project folder (where is located), enter the following command in the terminal.

    python startapp Boldreportsapp
  2. Now, edit in Boldreportsapp and add the code given below, which creates a single view for the app’s home page.

    from django.shortcuts import render
    from django.http import HttpResponse
    from django.template import loader
    # Create your views here.
    def boldreports(request):
     template = loader.get_template('index.html')
     return HttpResponse(template.render())
  3. Create a templates folder inside the Boldreportsapp folder, and create an HTML file named index.html.
  4. In the report_viewer.html file, you’ll need to include the necessary JavaScript code to create and configure the Bold Report Viewer. You can refer to the JavaScript documentation provided by Bold Reports for detailed instructions on displaying an SSRS RDL report in a JavaScript application: Javascript Report Viewer

    In that documentation, you will find step-by-step instructions on how to include the required JavaScript files, create an instance of the Bold Report Viewer, and load and display an SSRS RDL report.

    <!DOCTYPE html>
      <html xmlns="">
            <title>Report Viewer HTML page</title>
            <link href="" rel="stylesheet" />
            <script src=""></script>
            <!--Render the gauge item. Add this script only if your report contains the gauge report item. -->
            <script src=""></script>
            <script src=""></script>
            <script src=""></script>
            <script src=""></script>
            <script src=""></script>
            <script src=""></script>
            <!--Render the map item. Add this script only if your report contains the map report item.-->
            <script src=""></script>
            <!-- Report Viewer component script-->
            <script src=""></script>
            <script src=""></script>
            <!--Render the chart item. Add this script only if your report contains the chart report item.-->
            <script src=""></script>
            <script src=""></script>
            <div style="height: 600px; width: 950px;">
                  <!-- Creating a div tag which will act as a container for boldReportViewer widget.-->
                  <div style="height: 600px; width: 950px; min-height: 400px;" id="viewer"></div>
                  <!-- Setting property and initializing boldReportViewer widget.-->
                  <script type="text/javascript">
                     $(function () {
                              reportServiceUrl: "",
                              reportPath: '~/Resources/docs/sales-order-detail.rdl'
  5. To change the settings, click the in Embedsample and add the below line in the INSTALLED_APPS and then run this command: python migrate.

  6. Create a file, in Boldreportsapp and add the sample code given below.

    from django.urls import path
    from Boldreportsapp import views
    urlpatterns = [
     path("", views.boldreports, name="boldreports")
  7. The Embedsample folder also has a file, which is where URL routing is actually handled. Open in the Embedsample and add the code given below.

    from django.contrib import admin
    from django.urls import include, path
    urlpatterns = [
    path("", include("Boldreportsapp.urls"))

    Note: The above code pulls in the app’s Boldreportsapp/ using django.urls.include, which keeps the app’s routes contained within the app.

  8. Then finally, run the development server with python runserver and open a browser to output

Note: If the server is not running, navigate to the /Embedsample folder and then execute the above command in the terminal.