title: "TypeError at / argument 1 must be str, not PosixPath" in django ecommerce website
body: <p>I was building an eCommerce website using Django and Vue.Js. There was no issue while I was hosting the website in localhost. But when I deployed my website on Heroku an error is showing up &quot;TypeError at / argument 1 must be str, not PosixPath&quot;. Mainly an error in the jinja template.</p>
  <h1>code:</h1>
  <pre><code>{% for category in menu_categories %}
  .. statements ..
  {% endfor %}
  </code></pre>
  <blockquote>
  <p>buckler-ecom.herokuapp.com
  <a href="https://buckler-ecom.herokuapp.com" rel="nofollow noreferrer">The link to the deployed site</a></p>
  </blockquote>
  <h1>settings.py</h1>
  <pre><code>
  STRIPE_API_KEY_PUBLISHABLE = &quot;secret&quot;
  STRIPE_API_KEY_HIDDEN = &quot;secret&quot;
  
  RAZORPAY_API_KEY_PUBLISHABLE = &quot;secret&quot;
  RAZORPAY_API_KEY_HIDDEN = &quot;secret&quot;
  
  PAYPAL_API_KEY_PUBLISHABLE = &quot;secret&quot;
  PAYPAL_API_KEY_HIDDEN = &quot;secret&quot;
  
  import os
  
  from pathlib import Path
  
  BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
  
  
  SECRET_KEY = 'secret'
  
  DEBUG = True
  
  ALLOWED_HOSTS = ['127.0.0.1', 'buckler-ecom.herokuapp.com']
  
  EMAIL_HOST = 'localhost'
  EMAIL_PORT = 1025
  
  LOGIN_URL = 'login'
  LOGIN_REDIRECT_URL = 'cart'
  LOGOUT_REDIRECT_URL = 'frontpage'
  
  # Cart
  
  SESSION_COOKIE_AGE = 86400
  CART_SESSION_ID = 'cart'
  
  # Application definition
  
  INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.sitemaps',
      'django.contrib.staticfiles',
  
      'apps.cart',
      'apps.coupon',
      'apps.core',
      'apps.newsletter',
      'apps.order',
      'apps.store',
      'apps.userprofile'
  ]
  
  MIDDLEWARE = [
      'django.middleware.security.SecurityMiddleware',
      'whitenoise.middleware.WhiteNoiseMiddleware',
      '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 = 'eCom.urls'
  
  TEMPLATES = [
      {
          'BACKEND': 'django.template.backends.django.DjangoTemplates',
          'DIRS': [],
          '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',
                  'apps.store.context_processors.menu_categories',
                  'apps.cart.context_processors.cart'
              ],
          },
      },
  ]
  
  WSGI_APPLICATION = 'eCom.wsgi.application'
  
  
  # Database
  # https://docs.djangoproject.com/en/3.1/ref/settings/#databases
  
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.sqlite3',
          'NAME': BASE_DIR / 'db.sqlite3',
      }
  }
  
  
  # Password validation
  # https://docs.djangoproject.com/en/3.1/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/3.1/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/3.1/howto/static-files/
  
  STATIC_URL = '/static/'
  STATICFILES_DIRS = [
      os.path.join(BASE_DIR, 'static')
  ]
  MEDIA_URL = '/media/'
  MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
  </code></pre>
  <h1>views.py</h1>
  <pre><code>from django.shortcuts import render
  
  from apps.store.models import Product, Category
  
  def frontpage(request):
      products = Product.objects.filter(is_featured=True)
      featured_categories = Category.objects.filter(is_featured=True)
      popular_products = Product.objects.all().order_by('-num_visits')[0:4]
      recently_viewed_products = Product.objects.all().order_by('-last_visit')[0:4]
  
      context = {
          'products': products,
          'featured_categories': featured_categories,
          'popular_products': popular_products,
          'recently_viewed_products': recently_viewed_products
      }
  
      return render(request, 'frontpage.html', context)
  </code></pre>