import os
from django.conf import settings
from django.db.models.loading import get_models, get_app
default_app_config = 'calaccess_raw.apps.CalAccessRawConfig'


def get_download_directory():
    """
    Returns the download directory where we will store downloaded data.
    """
    if hasattr(settings, 'CALACCESS_DOWNLOAD_DIR'):
        return getattr(settings, 'CALACCESS_DOWNLOAD_DIR')
    elif hasattr(settings, 'BASE_DIR'):
        return os.path.join(getattr(settings, 'BASE_DIR'), 'data')
    raise ValueError("CAL-ACCESS download directory not configured. Set either \
CALACCESS_DOWNLOAD_DIR or BASE_DIR in settings.py")


def get_test_download_directory():
    """
    Returns the download directory where we will store test data.
    """
    if hasattr(settings, 'CALACCESS_TEST_DOWNLOAD_DIR'):
        return getattr(settings, 'CALACCESS_TEST_DOWNLOAD_DIR')
    elif hasattr(settings, 'BASE_DIR'):
        return os.path.join(getattr(settings, 'BASE_DIR'), 'test-data')
    raise ValueError("CAL-ACCESS test download directory not configured. \
Set either CALACCESS_TEST_DOWNLOAD_DIR or BASE_DIR in settings.py")


def get_model_list():
    """
    Returns a model list with all the data tables in this application
    """
    return get_models(get_app("calaccess_raw"))

import os
from django.conf import settings
from django.apps import apps as django_apps
default_app_config = 'calaccess_raw.apps.CalAccessRawConfig'


def get_download_directory():
    """
    Returns the download directory where we will store downloaded data.
    """
    if hasattr(settings, 'CALACCESS_DOWNLOAD_DIR'):
        return getattr(settings, 'CALACCESS_DOWNLOAD_DIR')
    elif hasattr(settings, 'BASE_DIR'):
        return os.path.join(getattr(settings, 'BASE_DIR'), 'data')
    raise ValueError("CAL-ACCESS download directory not configured. Set either \
CALACCESS_DOWNLOAD_DIR or BASE_DIR in settings.py")


def get_test_download_directory():
    """
    Returns the download directory where we will store test data.
    """
    if hasattr(settings, 'CALACCESS_TEST_DOWNLOAD_DIR'):
        return getattr(settings, 'CALACCESS_TEST_DOWNLOAD_DIR')
    elif hasattr(settings, 'BASE_DIR'):
        return os.path.join(getattr(settings, 'BASE_DIR'), 'test-data')
    raise ValueError("CAL-ACCESS test download directory not configured. \
Set either CALACCESS_TEST_DOWNLOAD_DIR or BASE_DIR in settings.py")


def get_model_list():
    """
    Returns a model list with all the data tables in this application
    """
    return django_apps.get_app_config('calaccess_raw').get_models()

Update get_model_list to use app config rather than deprecated django.db.models.loading functions
Update get_model_list to use app config rather than deprecated django.db.models.loading functions

  import os
  from django.conf import settings
- from django.db.models.loading import get_models, get_app
+ from django.apps import apps as django_apps
  default_app_config = 'calaccess_raw.apps.CalAccessRawConfig'
  
  
  def get_download_directory():
      """
      Returns the download directory where we will store downloaded data.
      """
      if hasattr(settings, 'CALACCESS_DOWNLOAD_DIR'):
          return getattr(settings, 'CALACCESS_DOWNLOAD_DIR')
      elif hasattr(settings, 'BASE_DIR'):
          return os.path.join(getattr(settings, 'BASE_DIR'), 'data')
      raise ValueError("CAL-ACCESS download directory not configured. Set either \
  CALACCESS_DOWNLOAD_DIR or BASE_DIR in settings.py")
  
  
  def get_test_download_directory():
      """
      Returns the download directory where we will store test data.
      """
      if hasattr(settings, 'CALACCESS_TEST_DOWNLOAD_DIR'):
          return getattr(settings, 'CALACCESS_TEST_DOWNLOAD_DIR')
      elif hasattr(settings, 'BASE_DIR'):
          return os.path.join(getattr(settings, 'BASE_DIR'), 'test-data')
      raise ValueError("CAL-ACCESS test download directory not configured. \
  Set either CALACCESS_TEST_DOWNLOAD_DIR or BASE_DIR in settings.py")
  
  
  def get_model_list():
      """
      Returns a model list with all the data tables in this application
      """
-     return get_models(get_app("calaccess_raw"))
+     return django_apps.get_app_config('calaccess_raw').get_models()
  
Update get_model_list to use app config rather than deprecated django.db.models.loading functions
## Code Before:
import os
from django.conf import settings
from django.db.models.loading import get_models, get_app
default_app_config = 'calaccess_raw.apps.CalAccessRawConfig'


def get_download_directory():
    """
    Returns the download directory where we will store downloaded data.
    """
    if hasattr(settings, 'CALACCESS_DOWNLOAD_DIR'):
        return getattr(settings, 'CALACCESS_DOWNLOAD_DIR')
    elif hasattr(settings, 'BASE_DIR'):
        return os.path.join(getattr(settings, 'BASE_DIR'), 'data')
    raise ValueError("CAL-ACCESS download directory not configured. Set either \
CALACCESS_DOWNLOAD_DIR or BASE_DIR in settings.py")


def get_test_download_directory():
    """
    Returns the download directory where we will store test data.
    """
    if hasattr(settings, 'CALACCESS_TEST_DOWNLOAD_DIR'):
        return getattr(settings, 'CALACCESS_TEST_DOWNLOAD_DIR')
    elif hasattr(settings, 'BASE_DIR'):
        return os.path.join(getattr(settings, 'BASE_DIR'), 'test-data')
    raise ValueError("CAL-ACCESS test download directory not configured. \
Set either CALACCESS_TEST_DOWNLOAD_DIR or BASE_DIR in settings.py")


def get_model_list():
    """
    Returns a model list with all the data tables in this application
    """
    return get_models(get_app("calaccess_raw"))

## Instruction:
Update get_model_list to use app config rather than deprecated django.db.models.loading functions
## Code After:
import os
from django.conf import settings
from django.apps import apps as django_apps
default_app_config = 'calaccess_raw.apps.CalAccessRawConfig'


def get_download_directory():
    """
    Returns the download directory where we will store downloaded data.
    """
    if hasattr(settings, 'CALACCESS_DOWNLOAD_DIR'):
        return getattr(settings, 'CALACCESS_DOWNLOAD_DIR')
    elif hasattr(settings, 'BASE_DIR'):
        return os.path.join(getattr(settings, 'BASE_DIR'), 'data')
    raise ValueError("CAL-ACCESS download directory not configured. Set either \
CALACCESS_DOWNLOAD_DIR or BASE_DIR in settings.py")


def get_test_download_directory():
    """
    Returns the download directory where we will store test data.
    """
    if hasattr(settings, 'CALACCESS_TEST_DOWNLOAD_DIR'):
        return getattr(settings, 'CALACCESS_TEST_DOWNLOAD_DIR')
    elif hasattr(settings, 'BASE_DIR'):
        return os.path.join(getattr(settings, 'BASE_DIR'), 'test-data')
    raise ValueError("CAL-ACCESS test download directory not configured. \
Set either CALACCESS_TEST_DOWNLOAD_DIR or BASE_DIR in settings.py")


def get_model_list():
    """
    Returns a model list with all the data tables in this application
    """
    return django_apps.get_app_config('calaccess_raw').get_models()
