title: I got http instead of https file path in Django
body: <p>I am working on a project where I users can upload pdf files and sign a signature on it. Although, this implementation works well on local machine which uses <code>http</code> requests, however after I deploy it on a server, the file path's uploaded to the server returns an <code>http</code> path instead of <code>https</code>.</p>
  <p>Here is models.py</p>
  <pre><code>from django.db import models
  from utils.mixins import BaseModelMixin
  import os
  from utils import pdf_processor
  from django.core.files.base import File
  import requests
  import time
  class DocumentFromUrl(BaseModelMixin):
      pdf_url = models.URLField()
      rental_bon_number = models.CharField(max_length=255)
      dossier = models.CharField(max_length=255)
      company = models.CharField(max_length=255)
      company_username = models.CharField(max_length=255)
      user_email = models.EmailField()
      client_email = models.EmailField()
      client_username = models.CharField(max_length=255)
      validity_date = models.CharField(max_length=255)
      language = models.CharField(max_length=255, null=True, blank=True)
      message = models.CharField(max_length=255, null=True, blank=True)
  
      pdf = models.FileField(null=True, blank=True, upload_to='url_pdf')
  
      fields = ['pdf_url', 'rental_bon_number', 'dossier', 'company', 'username',
                'user_email', 'client_email', 'client_username', 'language', 'message', &quot;validity_date&quot;]
  
      def download_pdf(self):
          filename = f'media/temp/{time.time()}.pdf'
          with requests.get(self.pdf_url, stream=True) as r:
              with open(filename, 'wb') as file:
                  for chunk in r.iter_content(chunk_size=1024):
                      file.write(chunk)
  
          return filename
  
      def save(self, *args, **kwargs):
          super().save(*args, **kwargs)
  
          if self.pdf:
              return
  
          downloaded_pdf = self.download_pdf()
          other_part = pdf_processor.pdf_from_dict(
              {x: y for x, y in self.__dict__.items() if x in self.fields})
          merged_files = pdf_processor.merge_pdf_files(
              [downloaded_pdf, other_part])
  
          self.pdf = File(open(merged_files, 'rb'),
                          name=merged_files.split('/')[-1])
          self.save()
  </code></pre>
  <p>As you see in the above code, <code>pdf</code> field stores the pdf path. But it stores the pdf path as <code>http</code> instead of <code>https</code>. What should I do to fix this issue?</p>
  <p>Here is settings.py</p>
  <pre><code>import os
  from pathlib import Path
  from decouple import config
  
  BASE_DIR = Path(__file__).resolve().parent.parent
  
  
  SECRET_KEY = config('SECRET')
  # SECRET_KEY = 'SECRET'
  
  DEBUG = config('DEBUG', True, cast=bool)
  
  ALLOWED_HOSTS = eval(config('ALLOWED_HOSTS', []))
  
  
  INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'rest_framework',
      'corsheaders',
      'rest_framework_simplejwt',
      'accounts',
      'rent',
  ]
  
  MIDDLEWARE = [
      'corsheaders.middleware.CorsMiddleware',
      'django.middleware.security.SecurityMiddleware',
      'django.contrib.sessions.middleware.SessionMiddleware',
      'corsheaders.middleware.CorsMiddleware',
      'django.middleware.common.CommonMiddleware',
      'django.middleware.csrf.CsrfViewMiddleware',
      'django.contrib.auth.middleware.AuthenticationMiddleware',
      'django.contrib.messages.middleware.MessageMiddleware',
      'django.middleware.clickjacking.XFrameOptionsMiddleware',
      'whitenoise.middleware.WhiteNoiseMiddleware',
  ]
  
  ROOT_URLCONF = 'app.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',
              ],
          },
      },
  ]
  
  WSGI_APPLICATION = 'app.wsgi.application'
  # If this is used then `CORS_ALLOWED_ORIGINS` will not have any effect
  
  CORS_ALLOW_ALL_ORIGINS = True
  
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.postgresql',
          'NAME': 'rent_plus_db',
          'USER': 'postgres',
          'PASSWORD': 'root',
          'HOST': '127.0.0.1',
          'PORT': '5432',
      }
  }
  # DATABASES = {
  #     'default': {
  #         'ENGINE': 'django.db.backends.sqlite3',
  #         'NAME': BASE_DIR / 'db.sqlite3',
  #     }
  # }
  
  REST_FRAMEWORK = {
      'DEFAULT_AUTHENTICATION_CLASSES': (
          'rest_framework_simplejwt.authentication.JWTAuthentication',
      )
  }
  
  
  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',
      },
  ]
  
  AUTH_USER_MODEL = 'accounts.User'
  
  LANGUAGE_CODE = 'en-us'
  
  TIME_ZONE = 'UTC'
  
  USE_I18N = True
  
  USE_TZ = True
  MEDIA_ROOT = BASE_DIR.joinpath('media')
  MEDIA_URL = 'media/'
  
  STATIC_URL = 'static/'
  STATIC_ROOT = BASE_DIR.joinpath('static')
  STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
  
  # Default primary key field type
  # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
  
  DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  </code></pre>