
from django.db.models import get_model

""" Several util functions for use in core functionality. """

def get_model_from_string(model):
    """ 
    Takes a string in the form of `appname.Model`, (ie.
    `basic_webshop.CartItem`) and returns the model class for it.
    """
    
    return get_model(*model.split('.'))


import logging
logger = logging.getLogger(__name__)

from django.db import models


""" Several util functions for use in core functionality. """


def get_model_from_string(model):
    """ 
    Takes a string in the form of `appname.Model`, (ie.
    `basic_webshop.CartItem`) and returns the model class for it.
    """
    model_class = models.get_model(*model.split('.'))
    
    assert isinstance(model_class, models.base.ModelBase), \
        '%s does not refer to a known Model class.' % model

    return model_class

Make sure we have actually looked up a model in get_model_from_string.
Make sure we have actually looked up a model 
in get_model_from_string.

  
- from django.db.models import get_model
+ import logging
+ logger = logging.getLogger(__name__)
+ 
+ from django.db import models
+ 
  
  """ Several util functions for use in core functionality. """
+ 
  
  def get_model_from_string(model):
      """ 
      Takes a string in the form of `appname.Model`, (ie.
      `basic_webshop.CartItem`) and returns the model class for it.
      """
+     model_class = models.get_model(*model.split('.'))
      
-     return get_model(*model.split('.'))
+     assert isinstance(model_class, models.base.ModelBase), \
+         '%s does not refer to a known Model class.' % model
  
+     return model_class
+ 
Make sure we have actually looked up a model in get_model_from_string.
## Code Before:

from django.db.models import get_model

""" Several util functions for use in core functionality. """

def get_model_from_string(model):
    """ 
    Takes a string in the form of `appname.Model`, (ie.
    `basic_webshop.CartItem`) and returns the model class for it.
    """
    
    return get_model(*model.split('.'))

## Instruction:
Make sure we have actually looked up a model in get_model_from_string.
## Code After:

import logging
logger = logging.getLogger(__name__)

from django.db import models


""" Several util functions for use in core functionality. """


def get_model_from_string(model):
    """ 
    Takes a string in the form of `appname.Model`, (ie.
    `basic_webshop.CartItem`) and returns the model class for it.
    """
    model_class = models.get_model(*model.split('.'))
    
    assert isinstance(model_class, models.base.ModelBase), \
        '%s does not refer to a known Model class.' % model

    return model_class
