django_importer/importers/base.py
def get_instance(self, data):
        """
        Get an item from the database or an empty one if not found.
        """
        # Get unique fields
        unique_fields = self.unique_fields
        
        # If there are no unique fields option, all items are new
        if not unique_fields:
            return self.model()
        
        # Build the filter
        filter = dict([(f, data[f]) for f in unique_fields])
        
        # Get the instance from the DB or use a new instance
        try:
            instance = self.model._default_manager.get(**filter)
        except self.model.DoesNotExist:
            return self.model()
        
        return instance
def get_instance(self, data):
        """
        Get an item from the database or an empty one if not found.
        """
        # Get unique fields
        unique_fields = self.unique_fields
        
        # If there are no unique fields option, all items are new
        if not unique_fields:
            return self.model()
        
        # Build the filter
        filter = dict([(f, data[f]) for f in unique_fields])
        
        # Get the instance from the DB or use a new instance
        try:
            instance = self.model._default_manager.get(**filter)
        except self.model.DoesNotExist:
            return self.model()
        
        return instance
Get an item from the database or an empty one if not found.