title: How to pass variables from the Django view to a template
body: <p>I want to pass a variable from views.py to home.html.
  I tried everything I could and I am new to django.</p>
  
  <p>It doesn't give any error but it doesn't display the variable as well.
  I may have made mistakes in url.py or settings.py</p>
  
  <p>settings.py</p>
  
  <pre><code>INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'project1'
  ]
  
  MIDDLEWARE = [
      'django.middleware.security.SecurityMiddleware',
      'django.contrib.sessions.middleware.SessionMiddleware',
      'django.middleware.common.CommonMiddleware',
      'django.middleware.csrf.CsrfViewMiddleware',
      'django.contrib.auth.middleware.AuthenticationMiddleware',
      'django.contrib.messages.middleware.MessageMiddleware',
      'django.middleware.clickjacking.XFrameOptionsMiddleware',
  ]
  
  ROOT_URLCONF = 'project1.urls'
  
  TEMPLATES = [
      {
          'BACKEND': 'django.template.backends.django.DjangoTemplates',
          'DIRS': [os.path.join(BASE_DIR, 'templates')],
          'APP_DIRS': True,
          'OPTIONS': {
              'context_processors': [
                  'django.template.context_processors.debug',
                  'django.template.context_processors.request',
                  'django.contrib.auth.context_processors.auth',
                  'django.contrib.messages.context_processors.messages',
              ],
          },
      },
  ]
  
  WSGI_APPLICATION = 'project1.wsgi.application'
  
  
  # Database
  # https://docs.djangoproject.com/en/2.2/ref/settings/#databases
  
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.sqlite3',
          'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
      }
  }
  
  
  # Password validation
  # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
  
  AUTH_PASSWORD_VALIDATORS = [
      {
          'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
      },
  ]
  
  
  # Internationalization
  # https://docs.djangoproject.com/en/2.2/topics/i18n/
  
  LANGUAGE_CODE = 'en-us'
  
  TIME_ZONE = 'UTC'
  
  USE_I18N = True
  
  USE_L10N = True
  
  USE_TZ = True
  
  
  # Static files (CSS, JavaScript, Images)
  # https://docs.djangoproject.com/en/2.2/howto/static-files/
  
  STATIC_URL = '/static/'
  </code></pre>
  
  <p>urls.py</p>
  
  <pre><code>from django.contrib import admin
  from django.urls import path, include
  from django.views.generic.base import TemplateView
  from django.conf import settings
  from django.conf.urls.static import static
  from . import views
  
  urlpatterns = [
      path('admin/', admin.site.urls),
      path('', TemplateView.as_view(template_name='home.html'), name='home'),
  ]
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>from django.http import HttpResponse
  from django.shortcuts import render
  
  def index(request):
      name = "kiran"
      key = 123
      context = {
          'name': name,
          'key': key,
      }
      return render(request, 'templates/home.html', context)
  </code></pre>
  
  <p>home.html</p>
  
  <pre><code>&lt;h&gt;hello&lt;/h&gt;
  &lt;h3&gt;{{key}}&lt;/h3&gt;
  </code></pre>
  
  <p>the page although displays hello but not {{key}}
  this is just an attempt to try if it's working but it is not working for me.</p>